A truckload of links which I need for some Bookmarklets work
Posted by jpluimers on 2024/12/31
A while ago, browser tabs were overflowing again so I first mad the list of links with quotes below, then discovered there is a template for many browser tabs open at [Wayback/Archive] To many browser tabs open Meme Generator – Imgflip
One of the reasons is that the WordPress “Press This” bookmarklet is very slow and also flaky at escaping HTML (for instance the below html – Why shouldn’t &apos; be used to escape single quotes? – Stack Overflow sometimes becomes html – Why shouldn’t <code>'</code> be used to escape single quotes? – Stack Overflow in [Wayback/Archive] Press This – WordPress plugin | WordPress.org especially when running it from Archive Today archived pages).
So here we go:
[Wayback/Archive] bookmarklet popup window with anchor – Google Search
- [Wayback/Archive] Ultra Random Thoughts: Simple Bookmarklet to get webpage link and title
- Get Link with title for webpage.
javascript:window.alert("<a%20href=\""+document.location.href+"\">"+document.title+"</a>"); - Get Link with title and a nofollow tag for a webpage.
javascript:window.alert("<a%20rel=\"nofollow\"%20href=\""+document.location.href+"\">"+document.title+"</a>"); - Get Link with title no follow and open in new tab or window for a webpage.
javascript:window.alert("<a%20rel=\"nofollow\"%20target=\"_blank\"%20href=\""+document.location.href+"\">"+document.title+"</a>");
- Get Link with title for webpage.
- Wayback/Archive] javascript – How a bookmarklet can avoid the popup blocker – Stack Overflow (very elaborate, thanks [Wayback/Archive] brandizzi and [Wayback/Archive] daamsie)
There is another way of working around the popup blocker by first including a link overlaid on the page and then allowing the user to click that to generate the popup. The bookmarklet javascript can then be stored in a separate file. This is how Pinterest’s bookmarklet manages to do it. First they select images from the page and overlay it directly on the page. Then when the user clicks to select one of the photos the popup appears. Because this action was initiated by the user, the popup works.
Here’s some code you can use to test:
…
- [Wayback/Archive] javascript – Creating a popup menu with bookmarklets – Stack Overflow (also very elaborate, thanks [Wayback/Archive] Questionable_Mushroom and [Wayback/Archive] Mr. Polywhirl)
You will need to create the pop-up menu using vanilla JS. I also implemented drag functionality. The only thing this needs is to correctly set the position when a page is scrolled.
…
[Wayback/Archive] bookmarklet to create new window with content – Google Search
- [Wayback/Archive] Just a little bookmarklet that will open a new window with a QR code for the current page’s URL
javascript:(function(){ window.open( 'http://chart.apis.google.com/chart?cht=qr&chs=512x512&chl=' + document.location.href,'qrcodepopup','width=700,height=700') })(); - [Wayback/Archive] javascript – How can I start a function in a new tab using a bookmarklet? – Stack Overflow (thanks [Wayback/Archive] Ylj and [Wayback/Archive] Hendrik) with the KeepVid JavaScript code archived in the WayBack machine web.archive.org/web/20140912042153/http://keepvid.com/js/bm.js
- [Wayback/Archive] SEO Bookmarklets for Busy Marketers (and How to Create Your Own) – Content Growth with many bookmarklets that are in this Google Sheet:
[Wayback/Archive] javascript html escape – Google Search
- [Wayback/Archive] HTML Escape Booktmark – I forgot the source (which was in itself escaped) that I unescaped
- [Wayback/Archive] Escape HTML – 30 seconds of code
JavaScript const escapeHTML = str => str.replace( /[&<>'"]/g, tag => ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[tag] || tag) );Examples escapeHTML('<a href="#">Me & you</a>'); // '<a href="#">Me & you</a>' - [Wayback/Archive] Unescape HTML – 30 seconds of code
JavaScript const unescapeHTML = str => str.replace( /&|<|>|'|"/g, tag => ({ '&': '&', '<': '<', '>': '>', ''': "'", '"': '"' }[tag] || tag) );Examples unescapeHTML('<a href="#">Me & you</a>'); // '<a href="#">Me & you</a>' - [Wayback/Archive] javascript – Escaping HTML strings with jQuery – Stack Overflow (thanks [Wayback/Archive] page and [Wayback/Archive] Tom Gruner)
There is also [Wayback/Archive] the solution from mustache.js
var entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=' }; function escapeHtml (string) { return String(string).replace(/[&<>"'`=\/]/g, function (s) { return entityMap[s]; }); } - [Wayback/Archive] javascript – Fastest method to escape HTML tags as HTML entities? – Stack Overflow (thanks [Wayback/Archive] callum, [Wayback/Archive] Web_Designer and [Wayback/Archive] Kevin Reilly)
Here’s one way you can do this:var escape = document.createElement('textarea'); function escapeHTML(html) { escape.textContent = html; return escape.innerHTML; } function unescapeHTML(html) { escape.innerHTML = html; return escape.textContent; } - [Wayback/Archive] How to escape HTML for use in JavaScript strings? – Stack Overflow (no code, but some guidance)
- [Wayback/Archive] Can I escape HTML special chars in JavaScript? – Stack Overflow (thanks [Wayback/Archive] fernando123, [Wayback/Archive] bjornd and [Wayback/Archive] dthree)
Here’s a solution that will work in practically every web browser:function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") .replace(/"/g, """) .replace(/'/g, "'"); }If you only support modern web browsers (2020+), then you can use the new replaceAll function:const escapeHtml = (unsafe) => { return unsafe.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", '''); } - [Wayback/Archive]
String.prototype.replaceAll()– JavaScript | MDN - [Wayback/Archive] html – Why shouldn’t `
'` be used to escape single quotes? – Stack Overflow (short answer: both backward compatibility – it is not valid HTML4 but is valid HTML5 – and semantics) - [Wayback/Archive] Character entity references in HTML 4
- [Wayback/Archive] JavaScript
escape()Method
–jeroen







Leave a comment