如何“反编译”一个书签?
我们都知道小书签只不过是一些 为我们做一些事情的可执行 JavaScript 代码 当我们根据它们的功能点击它们时 打算做...我的问题是:
例如,我有一个书签,不知道,像这样的:
javascript:void(window.open('http://www.pdfdownload.org/web2pdf/Default.aspx?left=0&right=0&top=0&bottom=0&page=0&cURL='+document.location.href));
据我所知,书签代码(带有“&cURL=”的东西)需要浏览器地址栏中的 URL,然后对其执行某些操作以获得结果。通过更改小书签中的一些参数(例如“Google 地图中的搜索选择”)和其他一些参数,可以通过选择来完成类似的操作。
如何“反编译”小书签以使其从表单中获取所需的数据(在本例中为 URL)?
例如,假设我想在网页中使用上述小书签来提供一个表单,让用户输入 URL,然后单击按钮获取结果。
我见过其他小书签从“?input=”获取 URL,还有其他小书签从“?url=”
获取 URL如何将小书签的函数传递到表单?
We all know that bookmarklets are nothing but some
executable javascript code that do some things for us
when we click on them depending on the function that they
are intended to do... My Question is:
For example, I have a Bookmarklet, don't know, something like this one:
javascript:void(window.open('http://www.pdfdownload.org/web2pdf/Default.aspx?left=0&right=0&top=0&bottom=0&page=0&cURL='+document.location.href));
As far as I understand, the bookmarklet code (with the "&cURL=" thing) takes the URL that is in the adress bar of the browser and then do something with it in order to get a result. Something similar can be done with a selection, by changing some parameters in the bookmarklet (Like with the "Search selection in Google Maps" one) and some others.
How can I "decompile" a bookmarklet in order to make it take the desired data (in this case an URL) from a form?
For example, let's say I want to use the above bookmarklet in a webpage to provide a form that let's the user input a URL and then click a button to get the result.
I've seen other bookmarklets that get the URL from a "?input=" and others from a "?url="
How can I pass bookmarklet's functions to a form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在小书签中,实际上最简单的方法是使用
prompt('请输入 URL', '默认值')
而不是变量。在当前网页中显示表单是比较麻烦的。如果您只需要一个用户输入的值,
prompt()
是一种易于使用的替代方法,可以向用户询问更多信息。 (当然,您也可以使用多个prompt()
调用,但这可能会导致用户感到困惑)In a bookmarklet it's actually easiest to use
prompt('Please enter a URL', 'default value')
instead of the variable. Displaying a form in the current webpage is rather cumbersome.If you just need one user-entered value,
prompt()
is an easy to use alternative to ask a user for more info. (Of course you can use multipleprompt()
calls, too, but this will probably lead to a confused user)尝试这样的事情:
Try something like this:
也许您可以在书签中调用 javascript 文件:
然后在 js.js 上创建一个 iframe
Maybe you can call a javascript file in your bookmarklet :
And you create an iframe on js.js