Initial commit
This commit is contained in:
30
code/bookmarklets/example-bookmarklet.js
Normal file
30
code/bookmarklets/example-bookmarklet.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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!`);})();
|
||||
*/
|
||||
Reference in New Issue
Block a user