Closing tabs when a chrome extension is disabled/reloaded - google-chrome-extension

I have a Chrome extension that opens a number of tabs, which it keeps open and uses to display data. I want those tabs to close when the extension is disabled or reloaded. My initial thought was that background.html would be unloaded when I restarted the plugin, but I can't seem to get anything that involves this to work. Any suggestions?

Chrome automatically closes pages with chrome-extension://<your_extension_id>/local.html urls (pages from the extension directory) when an extension is disabled. So if you can display your data using those pages - they will get closed. If it is some external site you are displaying - maybe you can make a local stub page with iframe and load your external site there.
Otherwise I can't think about any other way (besides having another extension watching this one).

i dont' know so much about chrome extensions, but, I think you are openning new windows by something like var w = window.open(params), so, you can close the window with w.close().
if not, ignore my answer :P

Related

Is it possible to move Google Chrome tab between windows? got it :)

Edit: Thank you wOxxOm. It worked :)
chrome.tabs.move(XXX,{windowId:YYY, index:ZZZ})
Somehow I did not see the move option :(
I am writing simple Google Chrome web extension and I want to manipulate the tabs and windows. I actually want to be able to move a tab between the windows. The tab will have programatically spawned dynamic page, that I do not want to reload. The windowId is not listed in the modifiable properties chrome.tabs.
Am I missing something or it is currently not supported? What are the workarounds?
p.s. In extreme case also powershell or .Net might be acceptable (I have total control of the target PC). Currently spawning clearly distinguishable iframe over the web pages (background script injected and message listener) but the iframe gets reloaded, which I want to avoid.
p.p.s. Workaround might be to detect the currently active window and spawn new tab in the active window (if required), but this would require to save the page state, close the inactive tab and spown new one in the active window (this should be possible)
p.p.p.s. Main target is Google Chrome, but want it also for Microsoft Edge. Hopefully also for other browsers.
Edit: Thank you wOxxOm. It worked :)
chrome.tabs.move(XXX,{windowId:YYY, index:ZZZ})
Somehow I did not see the move option :(

Creating a Chrome extension which closes blocked websites

I recently blocked quite a lot of ads across my entire network using AdGuard. Unfortunately, AdGuard does not prevent pop-up windows from opening. Although the advertising page is not called up, I get a popup which tells me that the requested page cannot be reached.
That's why I wanted to write a chrome extension that closes these popups automatically. Unfortunately, I fail to save the value of a checkbox in chrome.storage that is supposed to activate / deactivate the extension.
could someone help me here?
:EDIT
Okay i managed to store my value but now i'm running into the problem that i need to run a script when a page can't be loaded and i got no idea how i can do that. :S
Any Ideas? Is that even possible?

Re-using existing browser tabs when starting a new process

Right now I'm using Process.Start(URL_Here) to open a new page in the web browser - it will either open a browser or a new tab if one is already running. I was wondering, is there any reasonable (i.e. the one which won't require any 'hacks') way to re-use already opened tabs? - by "re-use" I mean a situation when f.e. www.google.com is already opened, I want to open a google page again, but instead of opening a new google tab it will redirect to the one that is already opened. Thanks for any help.
This sounds like standard browser behavior, and it's unlikely you'll be able to change it with simple command line arguments.
If you're willing to use Chrome and give every piece of data you transmit to The Company of Great Evil, then here's a plugin that can reuse a tab if you're using the same URL.

Watir: how to open a set of webpages in multiple tabs in IE9 or FF or Chrome?

I have a script that opens multiple URLs. Currently these URLs open in completely separate browser windows. I would like to open them in a single browser window with multiple tabs. I can use IE9 or the latest Chrome of Firefox. Is this possible?
I tried some things out, but I could not figure out a way to invoke a second tab through the API. I was able to set the IE tab settings to open links in a new tab. Then I created a page that had a link to a second page. When that link target="_blank", the second page opened in a new tab. Beyond that, I have no ideas.
What problem are you trying to solve with multiple tabs that wouldn't be solved with two browser instances?
Good luck,
Dave

Chrome extension performance

I have developed a chrome extension. The extension itself works fine and fast.
But when I start the browser and click on the toolbar icon of my extension it takes about 2 seconds for the popup to appear and to show its content (this happens anytime the browser is restarted).
Any idea what causes this and how to fix that?
Tip 1:
Use your popup page for rendering exclusively. It should be as light as possible. All the heavy loading/processing (localStorage, XMLHttpRequests, blocking javascript) must be done in the background page.
The background page is loaded when Google Chrome starts. Basically, it allows you to execute code and keep a page always running (although the popup is not present). For instance, streaming audio in a html5 tag with no popup.
Note: If you are not using a background page yet, you should be taking a look to message passing first.
Tip 2: Warning: This could fail
I haven't tested this yet, but maybe using the HTML5 manifest.cache can help you preventing loading again resources stored locally. But beware, this is HTML5 and is prone to changes and unstability across versions. (also, I am not completely sure that the cached resources will be loaded in memory before the popup is opened)
Hope it helps!

Resources