Skip to content

Instantly share code, notes, and snippets.

@yoko
Forked from taizooo/Endless_Summer_on_dsbd.user.js
Created September 22, 2010 01:34
Show Gist options
  • Save yoko/590960 to your computer and use it in GitHub Desktop.
Save yoko/590960 to your computer and use it in GitHub Desktop.
// ==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 http://gist.github.com/3242.txt
// @require http://gist.github.com/198443.txt
// @require http://gist.github.com/34615.txt
// @version 0.0.4.0.2
// ==/UserScript==
// requires AutoPagerize http://userscripts.org/scripts/show/8551 by swdyh
// using $X() http://gist.github.com/3242 by os0x
// using createDocumentFromString http://gist.github.com/198443 by os0x
// using wedata utility for GM http://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