Changing titles of inactive tabs with a chrome extension
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

If you've built chrome extensions before and have worked with the chrome.tabs api ( )
then I would be grateful if you help me figure out how to do things (such as changing the document.title) with multiple inactive tabs at once.

Please have a look at this Stack Overflow question:

awarded to radosinsky

Crowdsource coding tasks.

1 Solution

Winning solution


you can query for inactive tabs using chrome.tabs.query({active: false}, callback) (or leave the object empty if you want all tabs).

Then you'll need a script to change the title that you'll execute on each tab:
document.title = "INACTIVE TAB";

You also need to specify permissions for tabs and scripting in manifest.json file.

Here's full extension that will change all inactive tab titles to INACTIVE TAB on load:
(Download ZIP, extract, then load entire folder in Chrome Extensions page)

Let me know if this solves your problem or if you need help with anything else. Thanks!

Hello radonsinsky, I was mentioning the scripting solution, but I was hoping I could solve it without external scripts and do the renaming in the frontend. Because that's where I have the user input. I don't know how to pass it to the script file. And tbh having to use an extra script file just seems hacky and presumably, it's even a security risk.
j0hannes 1 month ago
Hey! You don't have to use script file, there's also an option to execute function. This function will be executed on the target, so you can easily use document.title to change the title. You can do this by changing files option to func. If you want to pass arguments to the function, you'll have to use args option. I updated the gist with example how to do this:
radosinsky 1 month ago
As for the security concerns, you can read here why V3 approach is much safer than V2 mentioned in your SO question:
radosinsky 1 month ago
You'll need to use "host_permissions": ["http://*/*", "https://*/*"], or <all_urls>, which is an alias for "*://*/*" (this will match all protocols, including, for example, file:// and ftp://.
radosinsky 1 month ago
Thank you! Now I am being told that I don't have host permission (even though I have it in the manifest). here's a 1min video demo:
j0hannes 1 month ago
Hey, I just tested the extension with https://*/* host permissions and it's working fine for me. Could you please double check that you've reloaded the extension with updated manifest.json and/or try setting host permissions to <all_urls>? Also please check if you're using manifest version 3. Does my extension from the gist work for you? If you're still having issues, would it be possible to send me your extension so I can test it? Thank you!
radosinsky 1 month ago
hey, only saw your answer just now. simply restarting my browser solved the host_permissions issue. I'll give you your well-earned bounty now, but I have another question for you in this video that I just recorded: it's about tabs, that are not loaded at all (and would be loaded from scratch when there were clicked) having an empty string "" as their url and therefore no document to modify. Maybe there is something that can be done? could I force all tabs of the current window to reload beforehand and how would that look?
j0hannes 1 month ago
to answer my own question: I found a 'discarded' property and was checking tab.discarded to chrome.tabs.reload( those that are discarded. then I was scratching my head, as it didnt work. But then I investigated the tab object and found a status properts. if (tab.status === "unloaded") { chrome.tabs.reload( } this works. though, there are a few tabs, that are clearly not loaded. but for some reason their status is "completed", so they wont get an emoji 🤷‍♂️ Anyways... I'm happy with the result. Thanks for your help radonsinsky
j0hannes 1 month ago