There are 9 previous versions of this script.
// ==UserScript==
// @name Digg autobury submissions
// @namespace http://userscripts.org/scripts/show/22300
// @version 0.3.3
// @description Automatically bury Digg submissions based on user name or keyword. Add users to 'var users_blacklist' and keywords to 'var keywords_blacklist' at the beginning of this script.
// @include http://digg.com/*
// @include http://www.digg.com/*
// ==/UserScript==
var users_blacklist = /GIMAD2008|mklopez|supernova17|schestowitz|mrbabyman|msaleem|digidave|zaibatsu/ig;
var keywords_blacklist = /scientology|xenu/ig;
var bury_interval = 10 ; //<--- 10 means 10 seconds delay between each bury!
var delay_on_page_load = 5 // <---- 5 seconds delay for starting the bury operation when a page loads
// ========================
// define your bury type - use the following numbers to indicate the type of your buries:
// for general bury, use 1
// for duplicate story, use 2
// for spam, use 3
// for wrong topic, use 4
// for inaccurate, use 5
// for OK, this is lame, use 6
var bury_type = 1 ;
// =========================
var $AutoBuryStories = {
show_infobar : true ,
html_root : '//html//body//div[@id="container"]//div[@id="contents"]//div[@id="wrapper"]',
init: function(){
try {
this.add_script('xpath1');
var enclosures = $xpath(this.html_root+'//div[contains(@id,"enclosure")]') ;
if (!enclosures) { return ; }
if (enclosures.snapshotLength == 1) {
this.bury_single_item(enclosures) ;
}
else {
this.bury_items(enclosures)
}
}
catch(e){ /* alert(e) ; */ }
},
bury_single_item: function(enclosures){
if (!($xpath(this.html_root+'//div[@id="enclosure1"]//ul//li[@id="diglink1"]').snapshotItem(0).innerHTML).match(/buried|dugg/ig)) {
var username1 = ($xpath(this.html_root+'//div[@id="enclosure1"]//div[@class="tool user-info"]//span[@class="user-info-text"]//a').snapshotItem(0).href).replace(/(.*)\/users\//,'');
var link_content1 = $xpath(this.html_root+'//div[@id="enclosure1"]//div').snapshotItem(0).innerHTML ;
if (username1.match(users_blacklist) || link_content1.match(keywords_blacklist)){
var bury_func1 = this.set_bury_func(bury_type,1) ;
window.setTimeout(''+bury_func1+'',1);
}
}
},
bury_items: function(enclosures){
var buried = 0 ;
var delay = 0 ;
var txt_tmp = '';
bury_interval = bury_interval * 1000 ;
for (var i=0, k=enclosures.snapshotLength; i<k; i++) {
if (!($xpath(this.html_root+'//div[@id="enclosure'+i+'"]//ul//li[@id="diglink'+i+'"]').snapshotItem(0).innerHTML).match(/buried|dugg/ig)) {
var username = ($xpath(this.html_root+'//div[@id="enclosure'+i+'"]//div[@class="news-body"]//p//em[2]//a').snapshotItem(0).href).replace(/(.*)\/users\//,'');
var link_content = $xpath(this.html_root+'//div[@id="enclosure'+i+'"]//div').snapshotItem(0).innerHTML ;
if (username.match(users_blacklist) || link_content.match(keywords_blacklist) ){
$xpath(this.html_root+'//div[@id="enclosure'+i+'"]').snapshotItem(0).style.display = 'none';
var bury_func = this.set_bury_func(bury_type,i) ;
var link = $xpath(this.html_root+'//div[@id="enclosure'+i+'"]//div[@class="news-body"]//h3[1]//a').snapshotItem(0) ;
var comments = $xpath(this.html_root+'//div[@id="enclosure'+i+'"]//div[@class="news-details"]//a').snapshotItem(0) ;
buried++ ;
delay = buried * bury_interval == bury_interval ? 1 : buried * bury_interval ;
if (this.show_infobar) {
txt_tmp += '<span id="autobury_info'+buried+'"><b>Waiting...</b></span> <a href="'+comments.href+'">'+(link.innerHTML).replace(/<span[^>]*>(.*?)<\/span>/ig,'')+'</a> <a title="original link" href="'+link.href+'" target="_blank"><img src="'+this.images.external+'" border="0"/></a> - submitted by <a href="/users/'+username+'/"> '+username+'</a><br/>';
window.setTimeout('document.getElementById("autobury_info'+buried+'").innerHTML="Working...";'+bury_func+';window.setTimeout(\'document.getElementById("autobury_info'+buried+'").innerHTML="Buried."\',2000);', delay );
}
else {
window.setTimeout(''+bury_func+'', delay );
}
}
}
}
if (buried > 0){
this.print_infobar(txt_tmp)
}
},
print_infobar : function(txt_tmp) {
if (this.show_infobar) {
txt_tmp = '<b>Autobury Submissions:</b><br/>'+txt_tmp ;
$xpath('//html//body//div[@id="container"]//div[@id="footer"]//div[@class="footer-contents"]').snapshotItem(0).innerHTML += '<div id="autobury_info_wrapper" style="width:80%;line-height:1.6;color:#556C31;background-color:#FFF8CE;margin:5px 0 0 0;float:left;padding:5px 10px;border: 1px dotted #2E6AB1"></div>';
$xpath('//html//body//div[@id="container"]//div[@id="footer"]//div[@class="footer-contents"]//div[@id="autobury_info_wrapper"]').snapshotItem(0).innerHTML = txt_tmp ;
}
},
set_bury_func : function(bury_type,i){
var bury_type_q = this.html_root+'//div[@id="enclosure'+i+'"]//div[@id="bury-tool_'+i+'"]' ;
var bury_txt = '';
switch(bury_type) {
case 1: bury_txt = bury_type_q+'//a' ; break ;
case 2: bury_txt = bury_type_q+'//div[@class="bury-opt menu"]//a[1]' ; break ;
case 3: bury_txt = bury_type_q+'//div[@class="bury-opt menu"]//a[2]' ; break ;
case 4: bury_txt = bury_type_q+'//div[@class="bury-opt menu"]//a[3]' ; break ;
case 5: bury_txt = bury_type_q+'//div[@class="bury-opt menu"]//a[4]' ; break ;
case 6: bury_txt = bury_type_q+'//div[@class="bury-opt menu"]//a[5]' ; break ;
default: bury_txt = bury_type_q+'//a' ;
}
return 'var button_'+i+' = $xpath(\''+bury_txt+'\').snapshotItem(0) ; var evt_'+i+' = document.createEvent("MouseEvents"); evt_'+i+'.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); button_'+i+'.dispatchEvent(evt_'+i+') ; ' ;
},
images : {
external : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAFVBMVEVmmcwzmcyZzP8AZswAZv////////9E6giVAAAAB3RSTlP///////8AGksDRgAAADhJREFUGFcly0ESAEAEA0Ei6/9P3sEcVB8kmrwFyni0bOeyyDpy9JTLEaOhQq7Ongf5FeMhHS/4AVnsAZubxDVmAAAAAElFTkSuQmCC' ,
},
add_script: function(script_id,innerhtml) {
if (!innerhtml || innerhtml == ''){ innerhtml = 'function $xpath(q,doc) { if (!doc || doc == \'\') {doc = document ; } return doc.evaluate(q, doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); }' ; }
var el = $xpath('//html//head').snapshotItem(0) ;
var script = document.createElement('script');
script.innerHTML = innerhtml ;
script.type = 'text/javascript';
script.id = script_id;
el.appendChild(script) ;
}
}
function $xpath(q,doc) { if (!doc || doc == '') {doc = document ; } return doc.evaluate(q, doc,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); }
(function() {
window.setTimeout( function(){
$AutoBuryStories.init();
}, delay_on_page_load * 1000 );
})();