// ==UserScript==
// @name Better Wolf Web
// @author Jonathan Hamilton - Enhanced by James Lewis
// @namespace http://jlhamilt.freeshell.org/
// @version 1.1
// @description Extensions for the Wolf Web
// @include http://thewolfweb.com/*
// @include http://*.thewolfweb.com/*
// @include http://brentroad.com/*
// @include http://*.brentroad.com/*
// @require https://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js
// @require http://lolibrary.org/bww/scaffold.js
// @require http://lolibrary.org/bww/gm_jq_xhr.js
// ==/UserScript==
// This variable gets used later. Basically, if there is a word or phrase you
// want to look for in thread titles, stick it here.
topicRegexp = ['nsfw', 'official', 'tww'];
function youtubeEmbed(videoID,listCode){return '';}
function dailymotionEmbed(videoID){return '';}
function facebookEmbed(videoID){return '';}
function myspaceEmbed(videoID){return '';}
function youtubeListEmbed(listID){return '';}
//Flash MP3 Player from http://flash-mp3-player.net/players/maxi/generator/
var mp3Player='http://jansal.net/player_mp3_maxi.swf';
function applyMediaEnhancements() {
messageLinks = $('div.post_message_content a');
messageLinks.filter('a[href*=.mp3]').each(function() {
mp3Link = $(this);
mp3LinkURL = mp3Link.attr("href");
mp3Link.replaceWith('
Download this MP3');
});
//YouTube support, including embed links, youtu.be, and playlists
messageLinks.filter('a[href*=youtube.com/watch]').each(function() {
videoLink=$(this).attr("href");
videoID=videoLink.replace(/^[^v]+v.(.{11}).*/,"$1");
listTest=videoLink.replace(/^.*list=(PL[A-F0-9]{16}).*/,"$1");
listCode=(listTest!=videoLink?"listType=playlist&list="+listTest:"version=2")+"&";
$(this).replaceWith(youtubeEmbed(videoID,listCode));
});
messageLinks.filter('a[href*=youtube.com/embed]').each(function() {
videoLink=$(this).attr("href");
videoID=videoLink.replace(/^[^d]+d.(.{11}).*/,"$1");
listTest=videoLink.replace(/^.*list=(PL[A-F0-9]{16}).*/,"$1");
listCode=(listTest!=videoLink?"listType=playlist&list="+listTest:"version=2")+"&";
$(this).replaceWith(youtubeEmbed(videoID,listCode));
});
messageLinks.filter('a[href*=youtu.be]').each(function() {
videoID = $(this).attr("href").replace(/^[^e]+be.(.{11}).*/,"$1");
$(this).replaceWith(youtubeEmbed(videoID,"version=2&"));
});
//YouTube playlists
messageLinks.filter('a[href*=youtube.com/playlist]').each(function() {
listID = $(this).attr("href").replace(/^.*=PL([A-F0-9]{16})$/,"$1");
$(this).replaceWith(youtubeListEmbed(listID));
});
messageLinks.filter('a[href*=youtube.com/course]').each(function() {
listID = $(this).attr("href").replace(/^.*=PL([A-F0-9]{16})$/,"$1");
$(this).replaceWith(youtubeListEmbed(listID));
});
//DailyMotion support
messageLinks.filter('a[href*=dailymotion.com/video]').each(function() {
videoID = $(this).attr("href").replace(/^[^e]+eo.(.{6}).*/,"$1");
$(this).replaceWith(dailymotionEmbed(videoID));
});
//Facebook support
messageLinks.filter('a[href*=facebook.com/video]').each(function() {
videoID = $(this).attr("href").replace(/^[^?]+\?v.([0-9]*).*/,"$1");
$(this).replaceWith(facebookEmbed(videoID));
});
//MySpace support
messageLinks.filter('a[href*=myspace.com/video]').each(function() {
videoID = $(this).attr("href").replace(/^.*\/(\d*)$/,"$1");
$(this).replaceWith(myspaceEmbed(videoID));
});
$('embed').attr("autostart", "false");
}
// Shortcut search!
function buildSearchForm() {
sectionName = "Message Boards";
sectionID = "";
if (location.href.match(/message_section\.aspx/)) {
sectionID = ' ';
sectionName = GM_getValue("current_section");
}
searchButton = $('a[href*="message_search.aspx"]');
searchButton.after('
No blocked users found.
"); } } function blockUsersInThreadsList() { // Don't show me threads by blocked users! blockedUsers = getBlockedUsers(); if (blockedUsers) { blockedUsers.forEach(function(value, index, array){ threadsToBlock = $('.thread_by_' + value.userid); threadsToBlock.addClass("blocked_thread"); $('a.user_link[href$="' + value.userid + '"]').attr("title", value.username).text("a blocked user"); }); if ($('.blocked_thread').size() > 0) { blockedThreadsBody = $(document.createElement('tbody')); blockedThreadsBody.attr("id", "blocked_threads").appendTo('#tww_thread_table').hide(); threadTableFoot = $(document.createElement('tfoot')); threadTableFoot.attr("id", "tww_thread_table_footer"); threadTableFootRow = $(document.createElement('tr')).appendTo(threadTableFoot).css("background-color", "#FFAAAA"); threadTableFootCell = $(document.createElement('td')).appendTo(threadTableFootRow).attr("colspan", "6").attr("align", "center"); blockedThreadsLink = $(document.createElement('a')).attr("id", "show_blocked_threads_link").attr("href", "#").addClass("plain"); blockedThreadsLink.appendTo(threadTableFootCell); blockedThreadsLink.text("Show blocked threads"); threadTableBody.before(threadTableFoot); $('#show_blocked_threads_link').bind("click", function(){ if ($('#show_blocked_threads_link').text() == "Show blocked threads") { $('#show_blocked_threads_link').text("Hide blocked threads"); } else { $('#show_blocked_threads_link').text("Show blocked threads"); } blockedThreadsBody.toggle(); return false; }); $('.blocked_thread').remove().appendTo('#blocked_threads'); } $('.tww_thread_row').filter(":even").attr("bgcolor", "#E3E3E3"); $('.tww_thread_row').filter(":odd").attr("bgcolor", ""); } } function hideMsg(msg) { console.log("hiding post " + msg.attr("id")); postCell = msg.parent(); hiddenMsg = msg.hide(); toggleLink = $(document.createElement('a')); toggleLink.attr("href", "#" + msg.attr("id").substr(8)); toggleLink.addClass("post_toggle"); toggleLink.text("Show this post"); postCell.prepend(toggleLink); toggleLink.append(hiddenMsg); toggleLink.bind("click", function() { postContent = $(this).children(); $(this).replaceWith(postContent); postContent.show(); }); }; function blockUsersInThread(usersToBlock) { blockedUsers = getBlockedUsers(); if (blockedUsers) { userIDsToBlock = []; blockedUserIDs = []; usersToBlock.forEach(function(value, index, array){ userIDsToBlock.push(value.userid); }); blockedUsers.forEach(function(value, index, array){ blockedUserIDs.push(value.userid); }); userIDsToBlock.forEach(function(value, index, array){ if (jQuery.inArray(value, blockedUserIDs) != -1) { $('.content_by_' + value).each(function() { msg = $(this); hideMsg(msg); }); } }); } } // This function just checks the document's URL against a regular expression and // calls different functions based on what it finds. There may be a better way // to do this later. function checkWolfWebURL() { currentURL = location.href; if (currentURL.match(/iframe/)){ return false; } else if (currentURL.match(/\/message\.aspx/)) { parseMessageBoardList(); buildSearchForm(); blockUsersInBoardList(); } else if (currentURL.match(/message_section\.aspx/)) { $("body").append(''); threadsList = parseThreadsList(); buildSearchForm(); blockUsersInThreadsList(); section = GM_getValue("current_section_id"); threadIDs = []; jQuery.each(threadListing, function(key, value){threadIDs.push(this.id);}); $.getJSON('http://lolibrary.org/bww/getvotes.php', { 'threads[]': threadIDs, section: section }, function(json){ if (json != null) { $.each(json, function(key, value){ $('#thread_' + value).addClass('nsfw'); }); //$('.nsfw').attr('bgcolor', '').css('backgroundColor','#ffb2b2'); $('.nsfw').find('td:first-child a').html('nsfw'); } }); } else if (currentURL.match(/message_topic\.aspx/)) { [postsInThread, usersInThread] = parseCurrentThread(); iFrame2Link(); applyMediaEnhancements(); blockUsersInThread(usersInThread); } else if (currentURL.match(/user\.aspx/)) { parseUserListPage(); } else if (currentURL.match(/user_info\.aspx/)) { currentUser = parseUserProfile(); addBlockLink(currentUser); } else if (currentURL.match(/photo_photo\.aspx/)) { parsePhotoPage(); } wolflink = $('a').eq(0).attr("id", "wolflink"); logo = wolflink.children("img").attr("id", "logo"); wolflink.replaceWith(logo); logo.after(wolfWebDialog("blocked_users_dialog", "Blocked users", "omg undefined content")); logo.bind("click", function() { renderBlockedUsers("#blocked_users_dialog_content"); $('#blocked_users_dialog').slideToggle("fast"); return false; }); }; // And the whole thing boils down to this stub. :P GM_registerMenuCommand("Clear blocked users list", function() { GM_deleteValue("blocked_users"); }); checkLogin(); checkWolfWebURL();