javascript - Chrome extension linker -
hello trying develop chrome extension new in please patient me, , sorry bad english far have done:
manifest.json
{ "name": "linker ", "manifest_version": 2, "version": "0.1", "description": "linker", "browser_action": { "default_icon": "icon.png", }, "content_scripts": [ { "matches": ["http://example.com"], "js": ["myscript.js"] } ], "permissions": [ "tabs", "http://*/*", "https://*/*" ] } myscript.js
function clickhandler(e) { chrome.tabs.update({url: "https://example.com"}); window.close(); } document.addeventlistener('domcontentloaded', function() { document.getelementbyid('bt_click').addeventlistener('click', clickhandler); }); my idea when plugin running on on website,using contenent script, once button pressed on specific website open other website on same tab or new tab.
the problem nothinng happens when doing wrong? want plugin once enabled run when specific website working. dont understand please great!!!!
if myscript.js supposed run content script, there's no need use this:
chrome.tabs.update({url: "https://example.com"}); to open url in current tab, execute:
// someurl url location.href = someurl so modify script in following way:
function clickhandler(e) { location.href = 'http://example.com'; } document.addeventlistener('domcontentloaded', function() { document.getelementbyid('bt_click').addeventlistener('click', clickhandler); }); fyi: code used in background scripts:
chrome.tabs.update
Comments
Post a Comment