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

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.

Related

How to close a url/website/tab using google chrome add-on?

So, imagine a person opening an online gaming website(for example krunker.io) in chrome, and what I want to know is whether there is a way to detect if a url(in this case "https://krunker.io/*") is open and to immediately close the tab(or the browser) using a Google Chrome addon(or even an outside application is fine).
The window.close() method does not work, as the person him/herself is the one who opens the tab/window, not the application
To close a tab, you can use the chrome.tabs.remove method.
// retrieve the id of the tab to close
$tabToCloseId = retrieveIdOfTabToClose(); //To write by yourself
chrome.tabs.remove($tabToCloseId);

Chrome extensions disable reopening of an extension created tab

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.

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