Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to run Javascript from address bar (bookmarklet) within Google Chrome's settings panel?

I would like to make a bookmarklet to open google chrome's settings panel and clear my cache with a single click.

For a while now, Ive had a bookmark that opens chrome's settings panel with the 'clear cache' setting already selected. After clicking the bookmark (normally opening it in a new tab) I have to then opent the tab and submit the form. However, when developing this is a task I have to do quite often and these several repeated steps just seem unnecessary.

This link opens the page to clear one's cache (obviously for Chrome users only): chrome://chrome/settings/clearBrowserData#cache

I recently discovered bookmarklets and thought it would be a good way to accomplish the task of clearing my cache with a single click. However, I've discovered that putting even a basic javascript sample in the address bar when on the settings page (linked above) fails to work.

For example, this works in the address bar on any given page, but not from the chrome settings page:

javascript:alert('hello stackoverflow');

Is there a way to execute javascript from the chrome settings page? Are there other options? Im looking for any route to achieve this goal and would love to learn something along the way, even if it means doing some evil. :)

like image 546
bradleygriffith Avatar asked Jun 18 '12 02:06

bradleygriffith


People also ask

How do you bookmarklet in JavaScript?

This is as simple as putting it in the href attribute of your link anchor. Now users can right-click and "Bookmark Link", or drag it to the bookmarks bar for easy access. Clicking the link on the web page will execute the script immediately.

How do I run a bookmarklet?

Just click the bookmarklet and your browser will run it on the current page. If you don't have a bookmarks toolbar — such as on Safari on an iPad or another mobile browser — just open your browser's bookmarks pane and tap or click the bookmark.


1 Answers

add a bookmark:

javascript:document.write('<form onsubmit="window.open(\'javascript:\'+js_line.value, \'target\');return false;">javascript:<input type=text name=js_line style="width:90%;"/></form><iframe src="" name="target" style="width:100%;height:90%;"/>');
like image 52
diyism Avatar answered Oct 17 '22 16:10

diyism