Skip to content

Instantly share code, notes, and snippets.

@stykalin
Last active August 6, 2020 13:14
Show Gist options
  • Save stykalin/0f24cc60b8ab7da96fd780cbda5daca6 to your computer and use it in GitHub Desktop.
Save stykalin/0f24cc60b8ab7da96fd780cbda5daca6 to your computer and use it in GitHub Desktop.
Run JS script as browser bookmark

To run some JS code as bookmark you need wrap your code in bookmark url as: javascript:(<here you code>)();

For example I generate GUUID this way:

javascript:(window.alert(([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15 >> c/4).toString(16))))();

For several rows code use: javascript:(function(){<here you code>})();

javascript:(function(){document.querySelector("input[name='login']").value=my_login;document.querySelector("input[name='password']").value=my_pass;})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment