Skip to content

Instantly share code, notes, and snippets.

@taizooo
Created November 18, 2008 17:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save taizooo/26170 to your computer and use it in GitHub Desktop.
Save taizooo/26170 to your computer and use it in GitHub Desktop.
Endless Summer on Tumblr Dashboard
// ==UserScript==
// @name Endless Summer on dsbd
// @namespace http://www.tumblr.com/
// @description random next link on tumblr dashboard
// @include http://www.tumblr.com/dashboard/1*
// @include http://www.tumblr.com/show/*/1*
// @require https://raw.github.com/gist/3242
// @require https://raw.github.com/gist/198443
// @require https://raw.github.com/gist/34615
// @version 0.0.4.0.4
// ==/UserScript==
// requires AutoPagerize http://userscripts.org/scripts/show/8551 by swdyh
// using $X() https://gist.github.com/3242 by os0x
// using createDocumentFromString https://gist.github.com/198443 by os0x
// using wedata utility for GM https://gist.github.com/34615 by youpy
// notice: put this script ABOVE AutoPagerize
// endlesSummeRize fire on http://www.tumblr.com/dashboard/1000 or http://www.tumblr.com/show/photos/by/everyone/1000 or ...
(function(){
var dsbd = 'http://www.tumblr.com/dashboard';
var DATABASE_URL = 'http://wedata.net/items/552.json';
var database = new Wedata.Database(DATABASE_URL);
var getId = function(info){
var opt = {
method: 'GET',
url: dsbd,
headers : {
},
onload: function(res) {
var i = $X(info.nextLink, createDocumentFromString(res.responseText));
if(i.length){
i = i[0];
}else{
return;
}
var cacheInfo = {
postNo : i.href.match(/.*\/\d+\/(\d+)/)[1],
nextLink : info.nextLink
};
GM_setValue('cacheInfo', JSON.stringify(cacheInfo));
}
};
GM_xmlhttpRequest(opt);
};
var endlessSummer = function(doc, url, info){
var cacheInfo = JSON.parse(GM_getValue('cacheInfo'));
if (!cacheInfo){
return;
}
var a = $X(cacheInfo.nextLink, doc);
if (a.length) {
a = a[0];
}else{
return;
}
a.href = location.pathname.replace(/(\/[^\/]+\/\d+)(\/\d+)/,'$1') + '?offset=' + Math.floor(Math.random() * cacheInfo.postNo);
a.textContent = 'Searching for The Endless Summer \u2192 ';
a.style.background='none repeat scroll 0 0 #4AADF0';
};
GM_registerMenuCommand('endless summer - clear cache', function() {
GM_setValue('cacheInfo', '');
database.clearCache();
});
database.get(function(items) {
getId(items.data);
});
endlessSummer(document, '', '');
setTimeout(function(){
if (window.AutoPagerize && window.AutoPagerize.addDocumentFilter){
window.AutoPagerize.addDocumentFilter(endlessSummer);
}
},0);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment