codeofnode
codeofnode

Reputation: 18609

How to redirect to an extension page in chrome?

In my web application i want to put a code that upon that execution it should redirect the current tab to some extension page?

If i do

window.location = 'chrome-extension://idgpnmonknjnojddfkpgkljpfnnfcklj';

it redirects me to 'about://blank' not on that particular extension page.

enter image description here

Can some one help me out how to achieve the same.

Upvotes: 5

Views: 1943

Answers (1)

Yevgen
Yevgen

Reputation: 1300

First of all you need to put all the resources of your chrome extension to the web_accessible_resources.

You also need to trigger redirect behavior. You can do it with content_scripts and you will need permissions for the specific domain.

Eventually you will have mainfest.json like:

    "permissions": [
        "*://example.com/*"
    ],
    "content_scripts": [{
        "js": ["injection.js"],
        "matches": ["*://www.example.com/*", "*://example.com/*"]
    }],
    "web_accessible_resources" : [
        "index.html",
        "main.js",
        "favicon.ico"
    ],

And injection.js like:

location = 'chrome-extension://'+chrome.runtime.id+'/index.html';

Upvotes: 2

Related Questions