javascript - Chrome extension to check a link and redirect to another website -


i building 1 extension in want block website urls chrome/firefox browser.

lets have list of urls want make blacklist. whenever chrome user wants join them, extension redirect url of choice (inside code determine url want be)

through research managed make chrome one

manifest.json

{     "name": "url block",     "description": "redirect site",     "version": "1.0",     "manifest_version": 2,     "background": {         "scripts": [             "background.js"         ]     },     "permissions": [         "webrequest",                     "*://facebook.com/*",             "*://www.facebook.com/*",             "*://apple.com/*",             "*://www.apple.com/*",             "*://iptorrents.com/*",             "*://www.iptorrents.com/*",         "webrequestblocking"     ] } 

background.js

var host = "http://www.google.com"; chrome.webrequest.onbeforerequest.addlistener(     function(details) {          return {redirecturl: host + details.url.match(/^https?:\/\/[^\/]+([\s\s]*)/)[1]};     },     {         urls: [             "*://facebook.com/*",             "*://www.facebook.com/*",             "*://apple.com/*",             "*://www.apple.com/*",             "*://iptorrents.com/*",             "*://www.iptorrents.com/*"         ],         types: ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"]     },     ["blocking"] ); 

so extension works perfect im trying do. have questions.

question:

lets want extension redirect 2 different url (and not in google.com in example above.) [which means, when put url: www.facebook.com , press enter, extension redirect tab www.google.com , open new tab redirect www.abc.com]

i don't know how in chrome firefox this:

how can change user agent in 1 tab of firefox? in solution instead of httpchannel.setrequestheader httpchannel.redirectto can read redirectto here: https://developer.mozilla.org/en-us/docs/xpcom_interface_reference/nsihttpchannel#redirectto%28%29


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -