Question

Is there any additional DOM exposed that a bookmarklet can access to get a list of the URLs of all the tabs that are currently open in a browser? I have done some searching but have found very little documentation on what can be done in a bookmarklet which cannot be done in a normal web page - although having written some bookmarklets already it seems they have a bit more privileged status than a normal web page (although this seems to vary by browser).

Was it helpful?

Solution

I have done some searching but have found very little documentation on what can be done in a bookmarklet which cannot be done in a normal web page

That is because there is essentially none. For all practical purposes, running a bookmarklet is exactly the same as running script on the page. It is almost precisely equivalent to clicking a link on the page that has href="javascript:.."

although having written some bookmarklets already it seems they have a bit more privileged status than a normal web page (although this seems to vary by browser).

I've have also written and researched a lot about bookmarklets (check my SO history). I have found only 2 significant differences.

1.) You can use %s in the bookmark's URL in combination with a bookmark keyword for argument substitution via the URL bar.

2.) There is a weird hack in Chrome (which could easily get closed with some future update) which lets a bookmarklet open a URL in a new tab and then run code in that tab if and only if the user does CTRL+click on the bookmarklet. But that still doesn't let you do anything to tabs which are already open.

If you know others, let me know.

The only solution is to create a browser extension. If you can write a bookmarklet, it isn't much more complicated to write a very basic extension.

OTHER TIPS

A bookmarklet is a javascript code that is being injected within a webpage;

If multiple tabs are available, the bookmarklet will be injected within the webpage of the current active tab.

The power of a bookmarklet is limitless, but it has effect only on 1 webpage, on the page that has been injected;

What you need here is a browser extension.

The extension gives you access to the browsers features;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top