How to "decompile" a bookmark?

We all know that bookmarklets are nothing but some javascript executable code that does something for us when we click on them depending on the function that they are intended for ... My question is:

For example, I have a bookmark, I don’t know, something like this:

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 I understand it, the bookmarklet’s code (with the "& cURL =" tag) gets the URL that is in the address bar of the browser, and then do something with it to get the result. Something similar can be done with the help of a choice, changing some parameters in the bookmarklet (for example, using the "Select Search on Google Maps") and some others.

How can I “decompile” the bookmarklet to get it to get the necessary data (in this case the URL) from the form?

For example, let's say I want to use the above bookmarklet on a web page to provide a form that allows the user to enter a URL, and then click a button to get the result.

I saw other bookmarklets that get the url from "? Input =" and others from "? Url ="

How to transfer bookmarklet functions to a form?

+3
source share
3 answers

A bookmarklet is actually easier to use prompt('Please enter a URL', 'default value')instead of a variable. Displaying a form on the current web page is rather cumbersome.

, prompt() - , . (, prompt(), , , )

0

- :

<form method="get" action="http://www.pdfdownload.org/web2pdf/Default.aspx">
<input type="hidden" name="left" value="0">
<input type="hidden" name="right" value="0">
<input type="hidden" name="top" value="0">
<input type="hidden" name="bottom" value="0">
<input type="hidden" name="page" value="0">
<input type="text" name="cURL">
<input type="submit">
</form>
0

Perhaps you can call the javascript file in your bookmarket:

javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('src','http://www.example.com/js.js');document.body.appendChild(e)})())

And you create iframe on js.js

var site = location.href;
document.body.innerHTML += "<div style='background-color:white;z-index:1000;position:fixed;right:0;top:0' width='300' height='250'><iframe src='http://www.example.com/bookmarklet.php?q=" + site + "' /></div>";
0
source

Source: https://habr.com/ru/post/1787045/


All Articles