How do I import scripts into a service worker using Chrome extension manifest version 3?

First off, important warnings: Warning: Chrome 92 or older doesn’t show errors occurred in the service worker – it was a bug, fixed in newer Chrome, which now shows the errors in chrome://extensions page. These old versions of Chrome can’t register the background script if an unhandled exception occurs during its compilation (a syntax error … Read more

Chrome New Tab Page extension steal focus from the address bar

ManifestV3 update This answer is adapted from https://stackoverflow.com/a/11348302/1754517. This has been tested with both Manifest V2 and V3. Tested in Google Chrome 99.0.4844.51 64-bit (Windows 10). Replace the content of focus.js with: if (location.search !== “?x”) { location.search = “?x”; throw new Error; // load everything on the next page; // stop execution on this … Read more

How to access the webpage DOM/HTML from an extension popup or background script?

ManifestV3 service worker doesn’t have any DOM/document/window. ManifestV3/V2 extension pages (and the scripts inside) have their own DOM, document, window, and a chrome-extension:// URL (use devtools for that part of the extension to inspect it). You need a content script to access DOM of web pages and interact with a tab’s contents. Content scripts will … Read more

How to fetch URL of current Tab in my chrome extension using javascript

Note you must have the tabs permission set in your manifest file “permissions”: [ “tabs” ], http://developer.chrome.com/extensions/tabs.html or the activeTab permission if initiated by a click on the extension button[Xan] https://developer.chrome.com/extensions/activeTab Code: chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ console.log(tabs[0].url); });

How to open new incognito window with Javascript? (Google Chrome)

Chrome extensions with the tabs permission can use the chrome.windows.create method: chrome.windows.create({“url”: url, “incognito”: true}); However, to access it, you’ll either need to write your own extension or find an existing one which provides a suitable hook (I don’t know whether this can be done with “Mouse Stroke”—I’m too scared to look).

Console shows error about Content Security policy and lots of failed GET requests

Let’s start with the easiest problem: Refused to execute inline script because … $(‘div’, this) selects all <div> elements within a <td>. In the source code you provided, the following event handler can be found: <div class=”smallfont”> <span style=”cursor:pointer” onclick=”window.open(‘member.php?u=47995’, ‘_self’)”>K4raMong</span> </div> By the default Content Security policy, this is forbidden. To get rid off … Read more