Posted December 23, 2015
Looks like you're most of the way there anyway.
To attach a button you just need to find somewhere on the page to add it and grab a reference to that element (forgive me, but I tend to use jQuery so need to look up the plain javascript stuff and it may not be 100% accurate) using
var div = document.getElementById('insertIdhere')
then create your link to click on (a button may be more appropriate, but I can never remember which is better)
var aTag = document.createElement('a');
and append that to the div
div.appendChild(aTag);
then just wrap your current code in a function and set the link to call it when you click it:
aTag.onclick = function() {};
As for passing it on to others to use, if they have something like TamperMonkey or GreaseMonkey you can just make a userscript (you just need to slap some headings on the top) and then host it somewhere like Gist (which I use for Fundamentals) and give them the link to install it.
If you're not using userscripts I'm not sure what alternatives there are.. I believe there is a way to save a javascript to your favourites (a Bookmarklet I think it's called) and just run it from your favourites menu.
To attach a button you just need to find somewhere on the page to add it and grab a reference to that element (forgive me, but I tend to use jQuery so need to look up the plain javascript stuff and it may not be 100% accurate) using
var div = document.getElementById('insertIdhere')
then create your link to click on (a button may be more appropriate, but I can never remember which is better)
var aTag = document.createElement('a');
and append that to the div
div.appendChild(aTag);
then just wrap your current code in a function and set the link to call it when you click it:
aTag.onclick = function() {};
As for passing it on to others to use, if they have something like TamperMonkey or GreaseMonkey you can just make a userscript (you just need to slap some headings on the top) and then host it somewhere like Gist (which I use for Fundamentals) and give them the link to install it.
If you're not using userscripts I'm not sure what alternatives there are.. I believe there is a way to save a javascript to your favourites (a Bookmarklet I think it's called) and just run it from your favourites menu.