Skip to content
Advertisement

How can I get the URL of the current tab from a Microsoft Edge extension

I’m experimenting with edge extensions , I’m trying to make one that reads the URL of the current tab, removes the string ‘%0A’ and then redirects to the cleaned URL, but I dont know how to read the current tab URL, I found how to do it in chrome:

JavaScript

but It doesnt seem to work for Edge, I have the permission for ‘tabs’ set in my manifest. Hope you can help me out

Advertisement

Answer

I suggest you refer to an example below that may help you to get the URL of the current tab from the Edge browser extension.

manifest.json:

JavaScript

background.html:

JavaScript

background.js:

JavaScript

The extension file structure looks like below. You can create other files by yourself(like CSS files etc).

enter image description here

Test result with the MS Edge 89.0.774.45:

enter image description here

Further, you can try to modify the code of the extension as per your own requirements.

Thanks for your understanding.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement