Chrome extensions disable reopening of an extension created tab - javascript

I couldn't find any similar question to this, but is it possible to create a new tab within chrome extension (using chrome.tabs.create) and then after closing it using the same extension prohibit user from reopening it using ctrl+shift+t or undo close tab command?

You can open an incognito tab; it will have the requested behavior.
I don't think you can clear session data, and simply clearing history does not prevent reopening.

Related

How to track the opening of a tab in a browser?

Some of the chrome extension opens third-party sites, I would like to determine which one. Maybe the window object contains information about what exactly opened the tab, but I could not find it. Or maybe there are other options?
Tried to find information about the open tab in the window object through devtools.

Google Chrome Extension, closing Persistent background page

I have a chrome extension which has a persistent background page in order to stream audio even when the user closes chrome. What I would like is to implement an option for the user to disable audio streaming after chrome has been closed. Right now I am detecting when all chrome windows have been closed and pausing audio, however chrome remains 'open' in the task manager and system tray (note that running in background chrome setting is enabled). This stops audio playback but the chrome process remains open in task manger and the icon remains in the system tray. By contrast if I completely disable the extension and then close chrome, the application closes completely and no system tray icon remains.
This Question suggests that only a user can explicitly close chrome if there is a persistent background page, My goal isn't to close chrome explicitly but simply prevent MY extension from being the one keeping chrome open (depending on user specified options), therefore an event page doesn't seem to be a good fit.
Is there a function call or some other programmatic way I can close my persistent background page once all windows have been closed, if that option has been enabled? Or am I stuck with the chrome application staying open because the background page is persistent?
I've found an answer to my own question so I'll post it here. In order to have a background page you do not need the "Background" permission declared in your manifest. This permission is what allows the extension to stay open after chrome has closed (and potentially open before chrome?) rather than being necessary to have a background page. So a persistent background page will close with chrome if this permission is not set, and will stay open even after chrome is closed if it is set.
Bearing this in mind, the solution for me was to set the "background" permission to optional, and enable it if I wanted my extension to stay open after close, then remove the permission if I didn't want it staying open after close (the user now has an option to toggle this).

Firefox addon: Window.open() vs CTRL-N

I created a simple firefox add on using addon-builder that installs & successfully appears in the add on toolbar at the bottom of the browser.
If I press ctrl-n, open new tab, open new window, or open private browsing window in firefox, then I see and can use my addon. However, if another site programmatically opens a window using window.open(), then my addon doesn't appear.
Is this by design? Or is there a setting that I can include in my addon so that it always appears, even if the window was opened through window.open() instead of ctrl-n?
When sites open with window.open, they specify which parts of the browser UI will show. You may be able to place it somewhere less likely to be removed, like the navigation toolbar. The add-ons toolbar sounds like it's going away soon, anyway.

How to get Chrome to open multiple sites in a new tab

I'm developing a tool that lets you open multiple pages at once with a shortcut, to be used for things like opening your daily sites or querying multiple search engines for a phrase. In Firefox, Internet Explorer and Opera, assuming you've unblocked pop-ups for the domain, the code works as expected.
Chrome, however, opens the sites in new windows instead of tabs if the links are opened automatically when the page loads. If openAll() is commented out and the button is clicked or a key is pressed, the pages open in tabs. Note it's calling the exact same function.
The best solution I've found (which isn't saying much) is the One Window extension. It works, but you can see the new window open then get sucked back in, and it keeps you from opening new Windows with Ctrl-N, forcing you to drag tabs out to use another Chrome window.
I can understand there not being a programmatic way to change this because it's a browser setting, but as a user of the tool it's annoying to have the sites all open in new windows. Is there a Chrome setting or extension that will open links in tabs when they're loaded without user input? I realize opening a bevy of windows is the very thing browsers aim to stop, but this is one time where I want to allow it.
<input id="openAllBtn" type="button" value="Open all links"> (Or press any key)
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
function openAll() {
window.open('http://yahoo.com/');
window.location.replace('http://www.bing.com/');
return false;
}
$(document).ready(function() {
$(document).bind('keypress', openAll);
$("#openAllBtn").bind("click", openAll);
openAll();
});
</script>
Here's a Fiddle of the code: http://jsfiddle.net/sfzjR/
Is there a Chrome setting or extension
that will open links in tabs when
they're loaded without user input?
Check out the create method in the chrome extension docs. By default it will open a new tab, you can optionally specify the window you want that tab to open in, and give the tab a url.

Open links in new tab in Firefox

I am developing an Firefox extension. How can all the links on a webpage to be opened in a new tab?
That's usually a configurable option in Firefox to handle new links, so they may override your extension with that.
However...
The code
Example Website
will allow you to click the appearing words [Example Website], and the link will open in the current window.
The code
Example Website
Opens the link in a new window/tab.
The only mildly dodgy thing is that target is now apparently deprecated by the W3C, which means that it's generally up to the browser ( and the user's preferences) as to how (or even if) it is handled. But for people who have their preferences set accordingly - in Firefox - that should work.
I found what I was after. I wanted gbrowser.addtab(this.href).
Press Ctrl while clicking on the link on Windows. Use cmd on OSX.

Categories

Resources