可以在Google Chrome设置面板中的地址栏(bookmarklet)中运行Javascript吗? [英] Possible to run Javascript from address bar (bookmarklet) within Google Chrome's settings panel?

查看:232
本文介绍了可以在Google Chrome设置面板中的地址栏(bookmarklet)中运行Javascript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个书签来打开谷歌浏览器的设置面板,并通过单击清除我的缓存。

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

有一段时间了,我已经有一个书签打开了chrome的设置面板,并且已经选择了clear cache设置。单击书签(通常在新选项卡中打开它)后,我必须打开选项卡并提交表单。然而,在开发这项任务时我必须经常这样做,而这几个重复的步骤似乎是不必要的。

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.

此链接打开清除一个缓存的页面(显然仅限Chrome用户):chrome:// chrome / settings / clearBrowserData #cache

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

我最近发现了bookmarklet,并认为通过单击完成清除缓存的任务是一个很好的方法。但是,我发现当在设置页面(上面链接)上时,甚至将基本的javascript样本放在地址栏中都无法正常工作。

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.

例如,这可行在任何给定页面的地址栏中,但不是来自Chrome设置页面:

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

javascript:alert('hello stackoverflow');

有没有办法从Chrome设置页面执行javascript?还有其他选择吗?我正在寻找实现这一目标的任何路线,并希望沿途学习一些东西,即使这意味着要做一些邪恶。 :)

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. :)

推荐答案

添加书签:

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%;"/>');

这篇关于可以在Google Chrome设置面板中的地址栏(bookmarklet)中运行Javascript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆