Misc Bookmarklets

Costas

Administrator
Staff member
Copy to clipboard
JavaScript:
javascript:(function(){navigator.clipboard.writeText('this is a test')})();

Search any site
JavaScript:
javascript:(function(){void(q=prompt('What are you looking for?',''));if(q)location.href='http://www.google.com/search?q=site%3A'+'online-tech-tips.com'+' '+escape(q)})()

View Wayback URL
JavaScript:
javascript:location.href='https://web.archive.org/web/*/'+location.href

Gmail This
JavaScript:
javascript:(function(){popw='';Q='';d=document;w=window;if(d.selection){Q=d.selection.createRange().text;}else if(w.getSelection){Q=w.getSelection();}else if(d.getSelection){Q=d.getSelection();}popw=w.open('http://mail.google.com/mail/s?view=cm&fs=1&tf=1&to=&su='+encodeURIComponent(d.title)+'&body='+encodeURIComponent(Q)+escape('%5Cn%5Cn')+encodeURIComponent(d.location)+'&zx=RANDOMCRAP&shva=1&disablechatbrowsercheck=1&ui=1','gmailForm','scrollbars=yes,width=680,height=575,top=175,left=75,status=no,resizable=yes');if(!d.all)setTimeout(function(){popw.focus();},50);})();

Outline (Paywall Bypass)
JavaScript:
javascript:void(window.open('https://outline.com/'+document.location.href));

View Hidden Password
JavaScript:
javascript: (function() { var s, F, j, f, i; s = ""; F = document.forms; for (j = 0; j < F.length; ++j) { f = F[j]; for (i = 0; i < f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; }} if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page."); })();

Shrink URL
JavaScript:
javascript:void(location.href='https://www.shrunken.com/index.html?agreeTerms=1&submitted=1&longUrl='+encodeURIComponent(location.href.replace('http://','')));

Enable Right-Click
JavaScript:
javascript:void(document.oncontextmenu = null)

Enable Text Selection
JavaScript:
javascript: (function() {function R(a) { ona = "on" + a; if (window.addEventListener) window.addEventListener(a, function(e) { for (var n = e.originalTarget; n; n = n.parentNode) n[ona] = null; }, true); window[ona] = null; document[ona] = null; if (document.body) document.body[ona] = null;} R("click"); R("mousedown"); R("mouseup"); R("selectstart"); })()

Find Shared Logins
JavaScript:
javascript: (function() { var url = ('http://www.bugmenot.com/view/' + escape(location.hostname)); w = open(url, 'w', 'location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=400,modal=yes,dependent=yes'); if (w) { setTimeout('w.focus()', 1000) } else { location = url } })();


Convert Page To PDF
JavaScript:
javascript:void(window.open('https://www.web2pdfconvert.com#' + location.href))

some uses 'window.open' and possible blocked by the browser, replace it with 'location.href='


src - https://www.online-tech-tips.com/cool-websites/the-12-best-bookmarklets-every-browser-should-have/



Query element by property + change element Style + force redraw
JavaScript:
javascript:(function(){

    document.querySelector('[aria-labelledby="xx_Label"]').style.cssText = "height: 20px; width: 500px !important;";

    document.querySelector('[role="dialog"]').style.cssText = "position: absolute; height: 100%; width: 90%; z-index: 10000; top: 0px; left: 100px;";

    //force to redraw - making the children elements to align proper.
    $(window).trigger('resize');

})()

Use of AJAX call
JavaScript:
// src - https://gist.github.com/aglobus/47ded4e65db838a07b95

(function() {
  var loaded = function(event) {
    var response = JSON.parse(event.target.responseText);
    var hits = response.hits;
    if (hits.length === 0) {
      alert('No results found on HN.');
      return true;
    }
    document.location.href = 'https://news.ycombinator.com/item?id=' + hits[0].objectID;
  };

  var d = document;
  var b = d.body;
  var s = d.createElement('script');

  var url = d.location.href;
  var api = 'https://hn.algolia.com/api/v1/search_by_date?query=';

  var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
  var domain = matches && matches[1];

  if (domain === 'hn.algolia.com')
    return;

  if (domain != 'news.ycombinator.com') {
    var queryUrl = url.split('?')[0].split('#')[0];

    var xhr = new XMLHttpRequest();
    xhr.addEventListener('load', loaded, false);
    xhr.open('GET', api + encodeURIComponent(queryUrl) + '&restrictSearchableAttributes=url', true);
    xhr.send();
  } else {
    var link = document.querySelector('.title a');
    if (link) {
      link = link.href;
      document.location.href = 'https://hn.algolia.com/?q=' + link;
    }
  }

})();

Prevent google from mangling the link when copying or clicking the link
JavaScript:
//https://gist.github.com/radiantly/e1c7319214c77fa007f323fc56cd0239#gistcomment-3907073
javascript:(function(){window.addEventListener("mousedown",(event)=>{event.stopImmediatePropagation();},true);})()

search with current URL and URL title
JavaScript:
javascript: (function () {    var url = 'https://google.com/?q=' + encodeURIComponent(window.location.href) + '&submit_title=' + encodeURIComponent(document.title);    var win = window.open(url, '_blank');    win.focus();})();

TwitterToNitter
JavaScript:
//https://github.com/no-gravity/TwitterToNitter
javascript:h=['nitter.it','nitter.snopyta.org','nitter.net']; location.href=location.href.replace(window.location.host,h[Math.floor(Math.random()*h.length)]);

kill-sticky, a bookmarklet to remove sticky elements and restore scrolling
JavaScript:
//https://github.com/t-mart/kill-sticky | https://alisdair.mcdiarmid.org/kill-sticky-headers/
javascript:(function()%7Bdocument.querySelectorAll(%22body%20*%22).forEach(function(node)%7Bif(%5B%22fixed%22%2C%22sticky%22%5D.includes(getComputedStyle(node).position))%7Bnode.parentNode.removeChild(node)%7D%7D)%3Bdocument.querySelectorAll(%22html%20*%22).forEach(function(node)%7Bvar%20s%3DgetComputedStyle(node)%3Bif(%22hidden%22%3D%3D%3Ds%5B%22overflow%22%5D)%7Bnode.style%5B%22overflow%22%5D%3D%22visible%22%7Dif(%22hidden%22%3D%3D%3Ds%5B%22overflow-x%22%5D)%7Bnode.style%5B%22overflow-x%22%5D%3D%22visible%22%7Dif(%22hidden%22%3D%3D%3Ds%5B%22overflow-y%22%5D)%7Bnode.style%5B%22overflow-y%22%5D%3D%22visible%22%7D%7D)%3Bvar%20htmlNode%3Ddocument.querySelector(%22html%22)%3BhtmlNode.style%5B%22overflow%22%5D%3D%22visible%22%3BhtmlNode.style%5B%22overflow-x%22%5D%3D%22visible%22%3BhtmlNode.style%5B%22overflow-y%22%5D%3D%22visible%22%7D)()%3B%0A

badass based on setTimeout
JavaScript:
javascript:(function(){ var funcs = [func1, func2, func3],    i = 0;  function callFuncs() {     funcs[i++]();     if (i < funcs.length) setTimeout(callFuncs, 1000); } setTimeout(callFuncs, 1000);  function func1(){     document.querySelectorAll('.image-medium')[0].click(); }  function func2(){     document.querySelectorAll(".list-group div[class=''] div")[17].click(); }  function func3(){     document.querySelectorAll(".list-group div[class='']")[1].querySelectorAll('div')[0].click(); } })();

Zoom set handle before join the meeting
JavaScript:
//https://www.thewdhanat.com/blog/set-zoom-display-name-before-joining-with-bookmarklet/
javascript:(function(){
        const searchParams = new URLSearchParams(window.location.search);
        searchParams.set("uname", "")
        window.location.search = searchParams;
      })()

Youtube Profile Videos Links Reveal
JavaScript:
(function(d) {
  [].forEach.call(d.querySelectorAll('ytd-rich-item-renderer > div > ytd-rich-grid-media > div > ytd-thumbnail > a'), function(e) {
        console.log(e.href);
  });
 
}(document));

web-testing-bookmarklets
JavaScript:
//https://github.com/satisfice/web-testing-bookmarklets
Grabs: the entire DOM and collates it by tag name (i.e. all the form objects will be listed together).
URIs: Lists every URI that it can find in the document, including links, image sources, iframes, etc.
Classes: Lists every class in the DOM, collated by tag name.
Hidden: Lists every element of the DOM that has an attribute equal to "hidden."
IDs: Lists every element of the DOM that has an ID, collated by tag name.
Innertext: Lists all the text associated with each element of the DOM.
Read/Write: Lists all the editable elements on the page.
Get Storage: Dumps the contents of Javascript-visible cookies, Local Storage, and Session Storage

ChatGPT - Summarize Selection Bookmarklet
JavaScript:
//source - https://news.ycombinator.com/item?id=35055461
//https://gist.github.com/jackdoe/ce5a60b97e6d8487553cb00aa43fe0c6#file-chatgpt-summarize-bookmarklet
//get API key by https://beta.openai.com/account/api-keys
javascript:(function(api_key) { var selection = window.getSelection().toString(); if (selection.length == 0) return; var xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.openai.com/v1/chat/completions"); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Authorization', 'Bearer ' + api_key); window.scrollTo({top: 0}); window.document.body.innerHTML = 'asking...'; window.document.body.style.backgroundColor = "white"; window.document.body.style.color = "black"; window.document.body.style.fontFamily = 'monospace'; window.document.body.style.fontSize = "16px"; window.document.body.style.margin = "auto"; window.document.body.style.padding = "1rem"; window.document.body.style.maxWidth = "60rem"; xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var response = JSON.parse(xhr.responseText); var summary = response.choices[0].message.content; window.document.body.innerHTML = summary } else { try { var e = JSON.parse(xhr.responseText); window.document.body.innerHTML = e.error.message } catch(e) { window.document.body.innerHTML = 'error asking.. check the console'; console.log(xhr) } } } }; var data = JSON.stringify({ "model": "gpt-3.5-turbo", "messages": [ {"role": "system", "content": "Summarize the following text as if you are Richard Feynman"}, {"role": "user", "content": selection} ] }); xhr.send(data);})("YOUR API KEY HERE")

find elements by type
JavaScript:
//https://rknight.me/please-expose-your-rss/
Array.from(document.getElementsByTagName('link')).find(l => l.type.includes('application/rss+xml'))?.href

AJAX and pass CORS
JavaScript:
javascript:(function(){ var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://corsproxy.io/?https%3A%2F%2Fwww.sklavenitis.gr%2Fsylloges%2Fprosfores%2F%3Fbrand%3D%25CE%2592%25CE%259B%25CE%2591%25CE%25A7%25CE%2591%25CE%259A%25CE%2597', true); xhr.setRequestHeader('Cache-Control', 'no-cache'); xhr.onload = function() { if (xhr.status >= 200 && xhr.status < 300) { if ( xhr.responseText.toLowerCase().indexOf("badge") > -1 ) alert("offer found"); else alert("NOT found"); } else { alert('Request failed with status:', xhr.status); } }; xhr.onerror = function() { alert('Request failed'); }; xhr.send(); })();

Indicate New/Unread HN stories
JavaScript:
//https://gist.github.com/SMUsamaShah/e7c9ed3936ba69e522f8cb38671f1da7
javascript:(function() { 'use strict'; const KEY_LAST_CLEAR = 'hackernews-rank-notifier-clear-time'; const KEY_RANK_STORE = 'hackernews-rank-notifier'; const KEY_COMMENT_STORE = 'hackernews-rank-notifier-comments'; const MAX_STORIES = 3000; const MAX_COMMENT_COUNT = 250; const NEW_STORY = "<b style='color:green'>(NEW) </b>"; const oldRanks = JSON.parse(localStorage.getItem(KEY_RANK_STORE)) || {}; const oldComments = JSON.parse(localStorage.getItem(KEY_COMMENT_STORE)) || {}; const stories = Array.from(document.getElementsByClassName('athing')); stories.forEach(function(story) { const id = story.id; let rank = story.querySelector('span.rank').innerText; rank = parseInt(rank.slice(0, -1)); const title = story.querySelector('.title a'); const commentsElement = story.nextSibling.querySelector('.subline>a:last-child'); let commentCountText; let commentCount = 0; if (commentsElement) { commentCountText = commentsElement.innerText.match(/([0-9]*) comment/); commentCount = (commentCountText) ? parseInt(commentCountText[1]) : 0; } if (id in oldRanks) { const rankChange = oldRanks[id] - rank; if (rankChange !== 0) { title.textContent = '(' + (rankChange > 0 ? '+' : '-') + Math.abs(rankChange) + ') ' + title.textContent; } const commentChange = commentCount - (oldComments[id] || 0); if (commentChange !== 0 && commentsElement) { const commentColor = "rgb(180, " + Math.max(200 - commentChange * 200 / MAX_COMMENT_COUNT, 0) + ", 0)"; commentsElement.innerHTML = '<span style="color:' + commentColor + '">(' + (commentChange > 0 ? '+' : '-') + Math.abs(commentChange) + ') </span>' + commentsElement.innerHTML; } } else { title.innerHTML = NEW_STORY + title.innerHTML; } oldRanks[id] = rank; oldComments[id] = commentCount; }); const topStoryIds = Object.keys(oldRanks).sort((a, b) => b - a).slice(0, MAX_STORIES); const newRanks = {}; const newComments = {}; topStoryIds.forEach(id => { newRanks[id] = oldRanks[id]; newComments[id] = oldComments[id]; }); localStorage.setItem(KEY_RANK_STORE, JSON.stringify(oldRanks)); localStorage.setItem(KEY_COMMENT_STORE, JSON.stringify(oldComments)); })();

Kill sticky headers
JavaScript:
// source https://alisdair.mcdiarmid.org/kill-sticky-headers/ | https://gist.github.com/alisdair/5670341
(function () {
  var i, elements = document.querySelectorAll('body *');

  for (i = 0; i < elements.length; i++) {
    if (getComputedStyle(elements[i]).position === 'fixed') {
      elements[i].parentNode.removeChild(elements[i]);
    }
  }
})();

tradingview[.]com - universal table parser
JavaScript:
javascript:(function(){ var output = '<table>'; document.querySelectorAll('[class^="values"]').forEach(parentElement => { var childElements = parentElement.querySelectorAll('[class^="value"]'); output+="<tr>"; childElements.forEach(child => { output+= "<td>" + child.textContent + "</td>"; }); output+="</tr>"; }); output+="</table>"; var wnd = open('', 'lnkswnd', 'width=400,height=500,top=0,left=0,scrollbars,resizable'); with(wnd.document) { var s = '<html><base target=_blank>'; writeln(output); void(close()); } })();


Replay your typing in a few lines of JavaScript
html2csv
 
Top