Instapaper Article Tools

By ElasticThreads Last update Feb 13, 2010 — Installed 483 times. Daily Installs: 9, 3, 10, 10, 0, 0, 1, 3, 1, 0, 0, 2, 3, 1, 12, 6, 2, 0, 1, 0, 5, 1, 1, 4, 0, 0, 2, 1, 3, 0, 2

There are 15 previous versions of this script.

// ==UserScript==
// @name	Instapaper Article Tools
// @version	1.62
// @description Adds a floating palette of buttons to articles which allows you to go back, archive and return to read later, toggle auto-scroll, or star an article.
// The star button is a bit of hack. Clicked once it will star the article and then disappear. This is because I can't
// figure out how to poll instapaper to find out if the article is starred. So if you star it, go back to instapaper's home page and remove the star, 
// this script can't tell. So the solution is to have the star button there to be clicked once. After that, it disappears. Anyone who knows how to do this right, please contact me.
// @include     *instapaper*
// @copyright 	2009+, ElasticThreads (http://elasticthreads.tumblr.com/)
// @license	(CC) Attribution Non-Commercial Share Alike; http://creativecommons.org/licenses/by-nc-sa/3.0/
// ==/UserScript==
	var y = String(window.location.href);
	if (y.indexOf('http://www.instapaper.com/go/')!=-1) {
		var hist = document.referrer,
		aPos = y.indexOf('go/'),
		bPos = aPos + 3,
		cPos = y.indexOf('/text'),
		artID = y.substring(bPos,cPos),
		skipStr = 'http://www.instapaper.com/skip/' + artID,
		starStr = 'http://www.instapaper.com/star_toggle/' + artID;
		if (hist.indexOf('http')==-1){
			hist = 'http://www.instapaper.com/u';
		}
		var archtools = document.createElement("div");
		archtools.id = "readTbarr";
		archtools.innerHTML = "\
		<div><a href=" + hist + " title='go back' id='return-now'>&#8598;</a>\
			<a href=" + skipStr + " title='archive and return to read later' id='archive-return'>&#8599;</a>\
			<a href='javascript:togglescrolling()' title='toggle auto-scroll' id='scroll-tog'>&#8595;</a>\
			<a href=" + starStr + " title='star this article' id='star-this'>&#65290;</a><\div>";
				var str = document.getElementById('story'); 
				str.parentNode.insertBefore(archtools, str);
		var heads = document.getElementsByTagName("head");
		var cssnode = document.createElement("style");
		var css = "*{}html{padding-left:90px;padding-right:90px;}#readTbarr{position:fixed !important;z-index:100 !important;top:170px !important;}#readTbarr div{position: relative;right:80px;}#readTbarr a{opacity:.35;text-indent:0px !important;line-height:28px;font-family:serif !important;font-style: normal;font-weight: normal;font-size:22px;text-decoration:none;}#readTbarr a:visited{display:none;}#archive-return{background:#afafaf !important;margin-bottom:10px !important;font-weight:bold !important;-webkit-border-radius:4px;border-color:#4e4e4e;border-width: .07em;border-style: solid;-moz-border-radius:4px;color:#FFFFFF !important;display:block !important;padding:0 !important;width:26px !important;height:26px;text-align:center;font-size:19px !important;}#star-this{background:#afafaf !important;margin-bottom:10px !important;font-weight:bold !important;-webkit-border-radius:4px;border-color:#4e4e4e;border-width: .07em;border-style: solid;-moz-border-radius:4px;color:#FFFFFF !important;display:block;padding:0 !important;width:26px !important;height:26px;text-align:center;}#return-now{background:#afafaf !important;margin-bottom:10px !important;font-weight:bold !important;-webkit-border-radius:4px;border-color:#4e4e4e;border-width: .07em;border-style:solid;-moz-border-radius:4px;color:#FFFFFF !important;display:block !important;padding:0 !important;width:26px !important;height:26px;text-align:center;opacity:.35 !important;}#scroll-tog{background:#afafaf !important;margin-bottom:10px !important;font-weight:bold !important;-webkit-border-radius:4px;border-color:#4e4e4e;border-width:.07em;border-style:solid;-moz-border-radius:4px;color:#FFFFFF !important;display:block !important;padding:0 !important;width:26px !important;height:26px;text-align:center;line-height:19px !important;opacity:.35 !important;}#readTbarr a:hover{opacity:1 !important;}";
		cssnode.type = "text/css";
		cssnode.appendChild(document.createTextNode(css));
		heads[0].appendChild(cssnode);
		var jsnode = document.createElement("SCRIPT");
		var scrolljs = "\
			var goscrolling = false;\
			var lastoffset = pageYOffset;\
			var aktiv = window.setInterval(scroll,150);\
			function scroll() {\
				if (goscrolling == true) {lastoffset = pageYOffset; window.scrollBy(0,1);}\
				if (lastoffset == pageYOffset) {goscrolling = false;}\
				}\
			function togglescrolling() {\
				document.getElementsByTagName('body')[0].focus();\
				if (goscrolling == false) { goscrolling = true;}\
				else {goscrolling = false;}\
		}";
		scrolljs.id = "togscroll";
		jsnode.type = "text/javascript";
		jsnode.appendChild(document.createTextNode(scrolljs));
		heads[0].appendChild(jsnode);
	}