Last active
February 12, 2024 20:56
Revisions
-
peerreynders revised this gist
Feb 12, 2024 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,9 @@ Resource: [Implementing bookmarklets in JavaScript](https://2ality.com/2011/06/i - Minify the finished bookmarklet, e.g. [Minify JS Online](https://minify-js.com/) - In the Bookmark Manager (Ctrl+Shift+O) choose “Add New Bookmark” under the “Organise” menu. - Specify a name. - In URL specify the `javascript:` scheme and delimeter and paste the minified bookmarklet at the end. e.g. ```JavaScript javascript:(()=>{const t=document.location.hash;if(t.length<2&&"#"!==t[0])return;const e=document.getElementById(t.slice(1));e&&e.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})})(); ``` -
peerreynders revised this gist
Feb 12, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ (() => { // Force Chrome to go to anchor const hash = document.location.hash; // bail if there is no anchor @@ -13,4 +13,4 @@ block: 'start', inline: 'nearest', }); })(); -
peerreynders revised this gist
Feb 12, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,4 @@ Resource: [Implementing bookmarklets in JavaScript](https://2ality.com/2011/06/i - Minify the finished bookmarklet, e.g. [Minify JS Online](https://minify-js.com/) - In the Bookmark Manager (Ctrl+Shift+O) choose “Add New Bookmark” under the “Organise” menu. - Specify a name. - In URL specify the `javascript:` scheme and delimeter and paste the minified bookmarklet at the end. -
peerreynders created this gist
Feb 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ Resource: [Implementing bookmarklets in JavaScript](https://2ality.com/2011/06/implementing-bookmarklets.html) - Implement bookmarklet as an [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE). - Test the IIFE in the console for a relevant page. - Minify the finished bookmarklet, e.g. [Minify JS Online](https://minify-js.com/) - In the Bookmark Manager (Ctrl+Shift+O) choose “Add New Bookmark” under the “Organise” menu. - Specify a name. - In URL specify the `javascript:` scheme and delimeter a paste the minified bookmarklet at the end. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ () => { // Force Chrome to go to anchor const hash = document.location.hash; // bail if there is no anchor if (hash.length < 2 && hash[0] !== '#') return; const target = document.getElementById(hash.slice(1)); // bail if nothing was found if (!target) return; target.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest', }); }