how to get current tabId from background page

getSelected has been deprecated. The new way to do it is: chrome.tabs.query( {currentWindow: true, active : true}, function(tabArray){…} ) If you want to perform some callback on the active tab, you can wrap the above as so: function doInCurrentTab(tabCallback) { chrome.tabs.query( { currentWindow: true, active: true }, function (tabArray) { tabCallback(tabArray[0]); } ); } For … Read more

Packaging a font with a Google Chrome extension

Choose your font. As example I’ll take “Stint Ultra Expanded”. There is example how to add it to your page: <link href=”http://fonts.googleapis.com/css?family=Stint+Ultra+Expanded” rel=”stylesheet” type=”text/css”> Take only the href and open it in browser. You’ll see something like this: @font-face { font-family: ‘Stint Ultra Expanded’; font-style: normal; font-weight: 400; src: local(‘Stint Ultra Expanded’), local(‘StintUltraExpanded-Regular’), url(http://themes.googleusercontent.com/static/fonts/stintultraexpanded/v1/FeigX-wDDgHMCKuhekhedWmdhyVWfbygZe-w47Q2x_f3rGVtsTkPsbDajuO5ueQw.woff) format(‘woff’); … Read more

Service worker registration failed. Chrome extension

Please find below the cause for your specific issue and the cause for not getting the details of failure in the console log. Before Chrome 93, the service worker file must be in the root path where manifest.json is. This is a limitation of Service Worker specification, relaxed for extensions since Chrome 93. If, for … Read more

How do you integrate Universal Analytics in to Chrome Extensions?

There’s an issue for that on Google code: The solution is to pass analytics your own protocol check function or simply null for no checking, in an official way. This has to come after ga(‘create’, …) : ga(‘set’, ‘checkProtocolTask’, null); // Disable file protocol checking. So you don’t need to modify the original analytics.js script. … Read more

Recommended size of icon for Google Chrome Extension

Both are correct ! They are for different sections/features: The former refers to the browser-action icon (displayed on the top-right corner of your browser-window, next to the address bar). It is only displayed if your extension registers a browser-action. The latter refers to icons used throughout the extension and browser, as is explained quite clearly … Read more

Chrome says my extension’s manifest file is missing or unreadable

Something that commonly happens is that the manifest file isn’t named properly. Double check the name (and extension) and be sure that it doesn’t end with .txt (for example). In order to determine this, make sure you aren’t hiding file extensions: Open Windows Explorer Go to Folder and Search Options > View tab Uncheck Hide … Read more

Chrome extension login best practices

You should always use OAuth 2.0 for authentication within extensions. Never pass the username/password because an attacker can simply steal such information. An example from Chromium regarding OAuth in extensions is Tutorial: OAuth. Additionally, there’s an experimental API available for OAuth 2.0, which is supposed to make the whole process a little easier. There’s a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)