A snippet of JavaScript stored in a bookmark.
- 2018-02-22 on Pale Moon 27.6.2 (32-bit) on Linux.
-
2018-01-29 on Pale Moon 27.6.2 (32-bit) on Linux.
- Also works via a keyword.
-
(date not recorded) on Firefox (version not recorded)
- Usable only by manually clicking the bookmark, and not usable with a keyword.
Howto / notes ∞
- Bookmarklets are JavaScript
- Debugging bookmarklets
-
/* comments are allowed */
- Nested comments are not possible.
// line comments
are not allowed; bookmarklets are concatenated into one line.
- Be careful about using (
);
) with a semicolon (;
). It's best to omit them entirely and use plain parentheses ()
). -
Whitespace is largely ignored, so you can use line breaks and indentation.
Debugging bookmarklets ∞
Then you can paste your code in the console. I highly recommend you use alert()
An example:
alert( window.location.href + "\n" + 'text' )
prepend and reload ∞
- Tested 2018-01-29 on Pale Moon 27.6.2 (32-bit) on Linux.
-
Tested 2021-06-02 on Brave Version 1.25.68 Chromium: 91.0.4472.77 (Official Build) (64-bit)
Save the current page in The Internet Archive Wayback Machine.
javascript:location.href='https://web.archive.org/save/'+window.location.host+window.location.pathname;
append and reload ∞
For MediaWiki, reset the page's cache ∞
Tested 2018-01-29 on Pale Moon 27.6.2 (32-bit) on Linux.
For the current page, append ?action=purge
and reload. For MediaWiki, this forces a page cache reset.
Example:
example.com/foo.php
to:
example.com/foo.php?action=purge
Bookmarklet:
javascript:window.location+=%22?action=purge%22;
search-and-replace (edit and reload) ∞
search-and-replace ∞
From the WordPress editor, view the page: ∞
- Tested 2018-02-22 on Pale Moon 27.6.2 (32-bit) on Linux.
-
Tested 2021-06-02 on Brave Version 1.25.68 Chromium: 91.0.4472.77 (Official Build) (64-bit)
Example:
https://blog.spiralofhope.com/wp-admin/post.php?post=22505&action=edit => https://blog.spiralofhope.com/?p=22505
Bookmarklet:
javascript:location.href=location.href.replace('wp-admin/post.php?post=','?p=').replace('&action=edit','')
imgur single-to-gallery ∞
Tested 2018-02-22 on Pale Moon 27.6.2 (32-bit) on Linux.
Example:
https://i.imgur.com/I9Lj42m.png => https://imgur.com/I9Lj42m
Bookmarklet:
javascript:location.href=location.href.replace('i.','').replace(/(\..{3}?$)/m,'')
prepend, and search-and-replace ∞
Save a currently-edited WordPress page in the Wayback Machine ∞
- Tested 2018-02-22 on Pale Moon 27.6.2 (32-bit) on Linux.
-
Tested 2021-06-02 on Brave Version 1.25.68 Chromium: 91.0.4472.77 (Official Build) (64-bit)
From the WordPress editor, save the page in The Internet Archive Wayback Machine.
Example:
https://blog.spiralofhope.com/wp-admin/post.php?post=22505&action=edit => https://web.archive.org/save/https://blog.spiralofhope.com/?p=22505
Bookmarklet:
javascript:location.href='https://web.archive.org/save/'+location.href.replace('wp-admin/post.php?post=','?p=').replace('&action=edit','')
If you use something like BlogText which has the edit URL appended with &classic-editor
then you can use
javascript:location.href='https://web.archive.org/save/'+location.href.replace('wp-admin/post.php?post=','?p=').replace('&action=edit','').replace('&classic-editor','')
Obsoleted ∞
remember passwords for any site ∞
From 2010-01-12. This was obsoleted by a Firefox addon (whose name has not been noted).
Bookmark this. Then visit it before signing into one of those pesky sites.
javascript:(function(){var%20ca,cea,cs,df,dfe,i,j,x,y;function%20n(i,what){return%20i+"%20"+what+((i==1)?"":"s")}ca=cea=cs=0;df=document.forms;for(i=0;i<df.length;++i){x=df[i];dfe=x.elements;if(x.onsubmit){x.onsubmit="";++cs;}if(x.attributes["autocomplete"]){x.attributes["autocomplete"].value="on";++ca;}for(j=0;j<dfe.length;++j){y=dfe[j];if(y.attributes["autocomplete"]){y.attributes["autocomplete"].value="on";++cea;}}}alert("Removed%20autocomplete=off%20from%20"+n(ca,"form")+"%20and%20from%20"+n(cea,"form%20element")+",%20and%20removed%20onsubmit%20from%20"+n(cs,"form")+".%20After%20you%20type%20your%20password%20and%20submit%20the%20form,%20the%20browser%20will%20offer%20to%20remember%20your%20password.")})();
Examples:
-
- You have to delete a character in your email address and re-type it for the password field to be filled again.
Does not work for:
Last updated 2022-08-18 at 16:45:53
Added "remember passwords for any site". Maybe it will be useful to someone, someday.
re-tested a few
Updated to deal with a quirk in a recent version of WordPress and BlogText.