31 lines
842 B
JavaScript
31 lines
842 B
JavaScript
/**
|
|
* Example Bookmarklet Template
|
|
*
|
|
* This is a template for creating browser bookmarklets.
|
|
* To use: Wrap in javascript: protocol and minify
|
|
*/
|
|
|
|
(function () {
|
|
"use strict";
|
|
|
|
// Example: Highlight all links on a page
|
|
const links = document.querySelectorAll("a");
|
|
links.forEach((link) => {
|
|
link.style.backgroundColor = "yellow";
|
|
link.style.padding = "2px";
|
|
});
|
|
|
|
// Show confirmation
|
|
alert(`Highlighted ${links.length} links!`);
|
|
})();
|
|
|
|
/**
|
|
* To convert to bookmarklet:
|
|
* 1. Minify the code
|
|
* 2. Wrap in: javascript:(function(){YOUR_MINIFIED_CODE})();
|
|
* 3. Add to browser bookmarks
|
|
*
|
|
* Example bookmarklet format:
|
|
* javascript:(function(){'use strict';const links=document.querySelectorAll('a');links.forEach(link=>{link.style.backgroundColor='yellow';});alert(`Highlighted ${links.length} links!`);})();
|
|
*/
|