Chrome extension: accessing localStorage in content script

Update 2016: Google Chrome released the storage API: https://developer.chrome.com/docs/extensions/reference/storage/ It is pretty easy to use like the other Chrome APIs and you can use it from any page context within Chrome. // Save it using the Chrome extension storage API. chrome.storage.sync.set({‘foo’: ‘hello’, ‘bar’: ‘hi’}, function() { console.log(‘Settings saved’); }); // Read it using the storage … Read more

Chrome extension is not loading on browser navigation at YouTube

YouTube has started a trial with pushState-based navigation. In general, such navigations can only be detected within content scripts by injecting code that intercept calls to history.replaceState / history.pushState (or by using the chrome.webNavigation.onHistoryStateUpdated event in the background page). The remainder of this answer is specific to YouTube. YouTube shows a (red) progress bar on … Read more

Chrome extension content script re-injection after upgrade or install

There’s a way to allow a content script heavy extension to continue functioning after an upgrade, and to make it work immediately upon installation. Install/upgrade The install method is to simply iterate through all tabs in all windows, and inject some scripts programmatically into tabs with matching URLs. Obviously, you have to do it in … Read more

Can you access chrome:// pages from an extension?

By default you cannot run on a chrome:// url page. However, there is an option in chrome://flags/#extensions-on-chrome-urls: Extensions on chrome:// URLs (Mac, Windows, Linux, Chrome OS, Android) Enables running extensions on chrome:// URLs, where extensions explicitly request this permission. You still have to specify pages that your extension can run on and wildcards are not … Read more

How to open the correct devtools console to see output from an extension script?

Your code is correct as written, it works and outputs to console. If you are not seeing it, then you are, probably, looking at the wrong console. 1. Firefox Mozilla describes what extension output can be seen in which console in their Debugging article. Browser Console The Browser Console no longer shows output from WebExtensions … Read more