IMHO, If the goal is to retrieve current URL, Then the best approach I could think of is to use Assistant API.
Tasker does this by setting itself temporarily as assistant, triggering the assistant button itself, and retrieve the extras. The extras varies depending on the screen context.
Say...