// The Pirate Bay Hide Dead Torrents, a Greasemonkey user script
// Version 0.2 - May 22, 2008
// Copyright 2007, 2008 Jordon Kalilich (http://www.theworldofstuff.com/)
// This program is free software: you may redistribute and/or modify
// it under the terms of the GNU GPL version 3 or any later version.
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name The Pirate Bay Hide Dead Torrents
// @namespace http://www.theworldofstuff.com/greasemonkey/
// @description Hides seedless torrents from The Pirate Bay search results.
// @include http://thepiratebay.org/search/*
// @include http://thepiratebay.org/recent
// @include http://thepiratebay.org/recent/*
// ==/UserScript==
var results = document.getElementById('searchResult');
if (results) {
var colLength = results.rows[0].cells.length;
GM_log(colLength);
for (i = results.rows.length - 1; i >= 1; i--) {
if ( (results.rows[i].cells[colLength - 2]) && (/^\s*0\s*$/.test(results.rows[i].cells[colLength - 2].innerHTML) == true) ) { // check second to last column
results.deleteRow(i);
}
}
}
updateNotifier();
// UPDATE NOTIFIER (Version 10: May 19, 2008)
// Usage Information: http://www.theworldofstuff.com/greasemonkey/updatenotifier.html
function updateNotifier() {
// PARAMETERS //
var scriptName = "The Pirate Bay Hide Dead Torrents";
var scriptURL = "http://userscripts.org/scripts/show/26691";
var scriptVersion = 0.2;
var updateURL = "http://www.theworldofstuff.com/greasemonkey/thepiratebay.txt";
var updateInterval = 3600;
// END OF PARAMETERS //
var checkForUpdates = GM_getValue('checkForUpdates', true);
if (checkForUpdates == true) {
var lastCheck = GM_getValue('lastCheck', 0);
var d = new Date();
var currentTime = Math.round(d.getTime() / 1000); // Unix time in seconds
if (currentTime >= lastCheck + updateInterval) {
GM_xmlhttpRequest({
method: 'GET',
url: updateURL,
headers: {'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey','Accept': 'text/plain',},
onload: function(responseDetails) {
if (responseDetails.status == 200) {
var info = responseDetails.responseText;
function createNotice(noticeText) {
var notice = document.createElement('div');
with (notice.style) { id = 'GMscriptnotice'; position = 'fixed'; top = '0px'; left = '0px'; width = '100%'; background = '#ffeb7c'; zIndex = '1000'; textAlign = 'center'; font = '12px sans-serif'; fontWeight = 'normal'; color = '#000'; padding = '5px 3px 5px 3px'; margin = '0px'; borderTop = '0px'; borderRight = '0px'; borderBottom = '1px solid #beaf5d'; borderLeft = '0px'; }
notice.innerHTML = noticeText;
document.getElementsByTagName('body')[0].appendChild(notice);
if (document.getElementById('offLink')) {
document.getElementById('offLink').addEventListener('click', function(event) {
event.stopPropagation();
event.preventDefault();
var confirmTurnOff = confirm('Are you sure you no longer want to be notified of updates to this script?');
if (confirmTurnOff) {
alert('You will no longer be notified of updates to ' + scriptName + '. You can change this preference in about:config.');
GM_setValue('checkForUpdates', false);
notice.parentNode.removeChild(notice);
}
}, true);
}
document.getElementById('closeLink').addEventListener('click', function(event) {
event.stopPropagation();
event.preventDefault();
notice.parentNode.removeChild(notice);
}, true);
}
var linkStyle = 'color: #00f; text-decoration: underline; font: 12px sans-serif';
if (info.match(/^[\d\.]+/)) {
var versionOnSite = info.match(/[\d\.]+/);
if (info.indexOf(';') > 0) {
scriptURL = info.split(";")[1];
}
if (versionOnSite > scriptVersion) {
createNotice('An update to the Greasemonkey user script "' + scriptName + '" is available. You are using version ' + scriptVersion + '.<br /><a href="' + scriptURL + '" style="' + linkStyle + '; font-weight: bold" id="upgradeLink">Review changes and upgrade to version ' + versionOnSite + '</a> <a href="#" style="' + linkStyle + '; font-weight: normal" id="offLink">Turn off these notifications</a> <a href="#" style="' + linkStyle + '; font-weight: normal" id="closeLink">Close</a>');
}
}
else if (info.indexOf('-') == 0) { // if the script will no longer be maintained
GM_setValue('checkForUpdates', false);
if (info.indexOf(';') == 1) {
scriptURL = info.split(";")[1];
createNotice('The Greasemonkey user script "' + scriptName + '" will no longer be updated.<br /><a href="' + scriptURL + '" style="' + linkStyle + '; font-weight: bold" id="upgradeLink">More information</a> <a href="#" style="' + linkStyle + '; font-weight: normal" id="closeLink">Close</a>');
}
}
}
}
});
GM_setValue('lastCheck', currentTime);
}
}
} // END OF UPDATE NOTIFIER