The upgrading of vBulletin to 4.1 seems to have broken the script, so I
decided to write a new one from scratch:
Code:
--------------------
// ==UserScript==
// @name Hide vBulletin 4.1 threads
// @description Ignore threads in vBulletin 4.1
// @include http://forums.slimdevices.com/*
// @require
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
var ignorelist;
function WipeList() {
ignorelist = {};
ignorelist.threads = [];
}
function IsInArray(id) {
var ii;
for (ii = 0; ii < ignorelist.threads.length; ii++) {
if (ignorelist.threads[ii].id == id) {
return true;
};
}
return false;
}
function CheckHideThread($li) {
var id = $li.attr('id');
if (typeof(id)!='undefined') {
id = id.substr(7);
if (IsInArray(id)) {
$li.addClass('ignored');
$li.find('span.ignorethread').hide();
$li.find('span.unignorethread').show();
} else {
$li.removeClass('ignored');
$li.find('span.unignorethread').hide();
$li.find('span.ignorethread').show();
}
}
return false;
}
function CheckHideThreads() {
$('li.threadbit').each(function() {
CheckHideThread($(this));
});
$('#numberofignoredthreads').text(ignorelist.threads.length);
return false;
}
$(document).ready(function() {
$('div.threadmeta').each(function() {
$(this).prepend('<div class="ignoremenu"><span
class="ignorethread igbtn">ignore</span><span class="unignorethread
igbtn">un-ignore</span></div>');
});
$('div#threadpagestats').append(' <div id="ignoreinfo"><span
id="doing">Hiding</span> <span id="numberofignoredthreads"></span> ignored
threads. <span id="clearthreadignore" class="igbtn">wipe</span><span
id="showignored" class="igbtn">show</span><span id="hideignored"
class="igbtn">hide</span></div>');
$('#clearthreadignore').click(function() {
if (confirm('This will wipe the list of ignored threads for all
subforums on this site. Are you really sure you want to do this?')) {
WipeList();
localStorage.setItem('vBulletinIgnoreThreadList',JSON.stringify(ignorelist));
location.href = location.href;
}
});
$('#showignored').click(function() {
$('.ignored').fadeIn();
$('#showignored').hide();
$('#hideignored').show();
$('#doing').text('Showing');
});
$('#hideignored').click(function() {
$('.ignored').fadeOut();
$('#hideignored').hide();
$('#showignored').show();
$('#doing').text('Hiding');
});
$('#hideignored').hide();
try {
ignorelist =
$.parseJSON(localStorage.getItem('vBulletinIgnoreThreadList'));
} catch(err) {
WipeList();
}
$('.ignorethread').click(function() {
var $li = $(this).parents('li.threadbit');
var thread = new Object;
var ii;
thread.id = $li.attr('id').substr(7);
if (confirm('Really ignore this thread?')) {
thread.title =
$li.find('h3.threadtitle').find('a.title').text();
thread.forumid =
$('form#thread_inlinemod_form').attr('action').substr(22);
if (!IsInArray(thread.id, ignorelist.threads)) {
ignorelist.threads.push(thread);
localStorage.setItem('vBulletinIgnoreThreadList',JSON.stringify(ignorelist));
$li.addClass('ignored');
CheckHideThreads();
if ($('#showignored').is(':visible')) {
$li.hide('slow');
}
}
}
});
$('.unignorethread').click(function() {
var $li = $(this).parents('li.threadbit');
var thread = new Object;
var ii;
thread.id = $li.attr('id').substr(7);
if (confirm('Really un-ignore this thread?')) {
var newlist = {};
newlist.threads = [];
for (ii = 0; ii < ignorelist.threads.length;ii++) {
if (ignorelist.threads[ii].id != thread.id) {
newlist.threads.push(ignorelist.threads[ii]);
}
}
ignorelist = newlist;
localStorage.setItem('vBulletinIgnoreThreadList',JSON.stringify(ignorelist));
$li.removeClass('ignored');
CheckHideThreads();
$li.show('slow');
}
});
CheckHideThreads();
$('div#ignoreinfo').css('padding-top','6px');
$('div.ignoremenu').css('float','right').css('font-size','smaller').css('cursor','pointer');
$('.igbtn').css('cursor','pointer').css('border','1px solid
#999').css('margin','4px').css('padding-left','2px').css('padding-right','2px').css('background-color','#eee');
$('.ignored').hide();
});
--------------------
Some improvements:
* Status message on top of page, e.g. "Hiding 5 ignored threads." (this
number is forum wide).
* Possible to view ignored threads.
* Possible to un-ignore ignored threads.
Installation:
Standard greasemonkey installation:
* Install Greasemonkey in Firefox.
* Make a text file named whatever.user.js
* Paste the script into the text file, and save.
* Drag and drop the file into Firefox.
Let me know if there are any problems with the script.
------------------------------------------------------------------------
Soulkeeper's Profile: http://forums.slimdevices.com/member.php?userid=35297
View this thread: http://forums.slimdevices.com/showthread.php?t=94286
_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/discuss