BookmarkleterSizeWatcher.js (feature idea; see my linked commit in my own fork)
@chriszarate
This week I made a simple bookmarklet that when clicked would add a "size watcher" feature to this (just by inserting a that gets updated as the Output textarea value changes).
Today on my own fork I updated index.html so this feature always exists at initial page load. Just thought I would share the idea, food for thought, see the commit below if you think it might be a good addition to the main properly-built version (I just manually updated my existing already-built files).
Thanks again for making this perfectly-simple perfect-for-my-frequent-use tool!
https://github.com/DarrenSem/bookmarkleter/commit/4ee3b0144ac6ac09b36be218cd797e7ff8fec5d5
Update: rewritten to be more clean and understandable
( and also prevent possibility of bug due to previous tricky code style e.g. if ( foo != ( foo = bar ) ) { )
https://github.com/DarrenSem/bookmarkleter/commit/5c3c8fa461e053805e2633d82bbce6e9f882e199
// BookmarkleterSizeWatcher.js
// 334 char
// javascript:void function(){function a(){let a,c,d=document.querySelector("#InputLabel"),e=document.querySelector("#Output"),f=document.createElement("span");d.parentNode.insertBefore(f,d),clearInterval(b),b=setInterval(()=>{c=e.value.length,a!=c&&(a=c,f.innerText=a?"("+a+")":"")},20),console.log("clearInterval("+b+")")}var b;a()}();
var timerSize;
function init() {
let sizePrev;
let sizeNext;
let elInput = document.querySelector("#InputLabel");
let elOutput = document.querySelector("#Output");
let elSize = document.createElement("span");
elInput.parentNode.insertBefore( elSize, elInput );
clearInterval(timerSize);
timerSize = setInterval( () => {
sizeNext = elOutput.value.length;
// console.log( "\n\n", elSize.innerText, sizePrev, sizeNext );
if (sizePrev != sizeNext) {
sizePrev = sizeNext;
elSize.innerText = (
sizePrev ? "(" + sizePrev + ")" : ""
);
};
// console.log( elSize.innerText, sizePrev, sizeNext );
}, 20 ) ;
console.log( "clearInterval(" + timerSize + ")" );
};
init();