Hello! Help with the problem: I wanted to make a simple extension to chrome, this is almost full 0 :). I need to operate with the address bar, if it is more specific, then I need to redirect it to different domains by clicking on the links from the popup (some localization switch). So I added my script a trace of content to all the necessary pages:
var host1 = location.pathname; chrome.runtime.sendMessage({url: location.pathname}); in the main script trace:
chrome.runtime.onMessage.addListener( function (request, sender, sendResponse) { var urls = request.url; }) document.addEventListener('DOMContentLoaded', function () { var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { (function () { var ln = links[i]; ln.onclick = function () { chrome.tabs.create({active: true, url: urls}); }; })(); } }) but in the place where the tab should be created - nothing happens. There is a hunch that the url itself comes later than onclics are formed, therefore they do not work. Tell me what am I doing wrong?
Thank!