There are 3 previous versions of this script.
// ==UserScript==
// @name Empornium Simplify 5.1.0
// @namespace http://www.userscripts.org
// @description simplifies empornium
// @version 5.1.0
// @date 2009-08-14
// @include *empornium.us/browse*
// ==/UserScript==
// ===================================================================================
// SCRIPT CONFIGURATION
var minSeeds = 1;
var extractPics = true;
var removeRatingColumn = true;
var removeUploaderColumn = true;
// ===================================================================================
// extremely useful function
function strBetween(source, strA, strB) {
var indA = (strA=='') ? 0 : source.indexOf(strA)+strA.length;
var indB = (strB=='') ? source.length : source.indexOf(strB, indA);
return source.substring(indA, indB);
}
// navigate dom, given id and array of branch #'s
// count only element nodes for cross browser compatibility
function navDOM(id, path) {
// if id is string, navigate to that id
// otherwise it's an object, so navigate children only
if(typeof(id) == 'string') {var elem = env.getElementById(id);}
else {var elem = id;}
for (var i=0; i<path.length; i++) {
var childI = 0;
for (var j=0; j<elem.childNodes.length; j++) {
if(elem.childNodes[j].nodeType == 1) {
if(childI++ == path[i]) {
elem = elem.childNodes[j];
break;
}
}
}
}
return elem;
}
// given string of html source, get all picture links
function getPicsLinks(htmlSource, rowID) {
htmlSource = strBetween(htmlSource, 'Peers', 'Add Comment');
while (true) {
// get link element
link = strBetween(htmlSource, 'fullpic.php', 'a>');
link = link.replace("'>", ">");
imgI = htmlSource.indexOf('fullpic.php');
if (imgI == -1) {break;}
linkElem = '<a href="http://www.empornium.us/fullpic.php' + link + 'a>';
htmlSource = htmlSource.substring(imgI+21);
// insert into html
row = document.getElementById(rowID);
td = document.createElement('td');
td.innerHTML = linkElem;
row.appendChild(td);
}
}
function getPics(link, rowID) {
GM_xmlhttpRequest({
method: 'GET',
url: link,
onload: function(responseDetails) {
getPicsLinks(responseDetails.responseText, rowID);
}
});
}
function setDownloadLink2(htmlSource, rowID) {
dlLink = 'http://down.empornium.us/download' + strBetween(htmlSource, 'dlwin2', '.torrent') + '.torrent';
row = document.getElementById(rowID);
navDOM(row, [2,0]).href = dlLink;
}
function setDownloadLink1(link, rowID) {
GM_xmlhttpRequest({
method: 'GET',
url: link,
onload: function(responseDetails) {
setDownloadLink2(responseDetails.responseText, rowID);
}
});
}
// START PAGE MANIPULATION
// remove low seeds, extract pictures
var tbody = document.getElementsByTagName('tbody')[13];
if (removeUploaderColumn) {
navDOM(tbody, [0]).removeChild(navDOM(tbody, [0, 8]));
}
if (removeRatingColumn) {
navDOM(tbody, [0]).removeChild(navDOM(tbody, [0, 5]));
}
for (var i = tbody.childNodes.length-1; i >= 0; i--) {
thisLink = navDOM(tbody, [i,1,0]).href;
if (!/details.php/.test(thisLink)) {continue;}
thisID = "row" + i;
thisRow = navDOM(tbody, [i]);
thisRow.id = thisID;
// remove breaklines in title
nameNode = navDOM(tbody, [i,1]);
nameNode.innerHTML = nameNode.innerHTML.replace(/<br>/g, '');
// removes items with seeds below the threshold
thisDownloadLink = navDOM(tbody, [i,2,0]).href;
var thisSeeds = Number(navDOM(tbody, [i,7,0]).innerHTML);
if (thisSeeds < minSeeds) {
tbody.removeChild(navDOM(tbody, [i]));
continue;
}
if (removeUploaderColumn) {
thisRow.removeChild(navDOM(thisRow, [9]));
}
if (removeRatingColumn) {
thisRow.removeChild(navDOM(thisRow, [5]));
}
if (extractPics) {getPics(thisLink, thisID);}
// change download link to direct link
setDownloadLink1(thisLink, thisID);
}
// simplify page
var table = document.getElementsByTagName('table')[1];
table.parentNode.removeChild(table);
table = document.getElementsByTagName('table')[1];
var td1 = navDOM(table, [0,0,0]);
var td2 = navDOM(table, [0,0,2]);
td1.parentNode.removeChild(td1);
td2.parentNode.removeChild(td2);
// ===================================================================================
// autochecks for updates to script
var GM_update = function(title, version, updateUrl, versionUrl) {
var title = title;
var today = new Date();
today = today.getDate();
var last = GM_getValue(title);
var current;
var answer;
var updateUrl = updateUrl;
var versionUrl = versionUrl;
this.init = function() {
if(last != undefined) {
if(today - last >= 3 || today - last <= -24) {
GM_setValue(title, today);
this.check();
}
}
else {
GM_setValue(title, today);
this.check();
}
}
this.check = function() {
GM_xmlhttpRequest({
method:"GET",
url:versionUrl,
onreadystatechange:this.finish
});
}
this.finish = function(o) {
if(o.readyState == 4) {
current = o.responseText;
current = current.split(".");
version = version.split(".");
if(version[0] < current[0]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else if(version[1] < current[1]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else if(version[2] < current[2]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else {
// up to date
}
}
}
//start
this.init();
}
GM_update('Empornium Simplify', '5.1.0', 'http://userscripts.org/scripts/show/25734', 'http://bettertube.googlepages.com/version_empornium_simplify.txt');
