// ==UserScript==
// @name Warez-BB +
// @version 0.6
// @description Cleans up topic titels on Warez-BB
// @author FuSiOn
// @match https://www.warez-bb.org/viewforum.php?f=*
// @match http://forum.dirtywarez.com/*
// @match https://www.warez-bb.org/search.php*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @icon http://s10.postimg.org/vklswq3b9/WBB_CU.png
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @run-at document-end
// @namespace https://greasyfork.org/users/10999
// ==/UserScript==
var forumSection,
testing = false,
fileHosts,
RegEX = {
"movies": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?[|\])])\s?)*)(.+?)([.\(\[\s](?:19|20)\d{2}(?:[-+](?:19|20)\d{2})?(?:[.\]\)\s]|$))(.*$)/i,
"tv": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?[|\])])\s?)*)(.+?)()((?:[\[(]\s?)?(?:(?:(?:s?\d{1,2}-?)?e\d{1,2})|\d{1,2}x\d{1,2}|(?:(?:s|seasons?)\s?\d{1,2}(?:(?:-|\s)\d{1,2})*)|0?1(?:-\d{1,2})+|\d{1,2}[-\/.]\d{1,2}[-\/.]\d{4}|\d{4}[-\/.]\d{1,2}[-\/.]\d{1,2}|\w{3}.{1,2}\d{1,2}.{1,2}\d{4}|(?:19|20)\d{2}|\||complete|dvdrip|(?:mini-)?series?|blu-ray|hdtv|720p|1080p)(?:\s?[\])])?.*$)/i,
"episode": /(?:S\d{1,2}[\s-]E\d{1,2}[-\s]E\d{1,2}|S?\d{1,2}-?e\d{1,2}|\sE\d{1,2}(?:-?E\d{1,2})?|\d{1,2}x\d{1,2}|season\s\d{1,2}.?\sepisode\s\d{1,2})/i,
"season": /(?:\s|^)(?:S|seasons?)\s?(\d{1,2}(?:(?:-|\s)S?\d{1,2})*)(?![\dE]|.{1,2}episode)/i,
"games": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:\s?[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?\s?[|\])])\s?)*)(.+?)()((?:-?\s?[\[(+]?\s?)?(?:\W(?:V|PATCH|BUILD|UPDATE)\W?\V?[(\[]?(?:\d+\.?)|\d+\.(\d+\.)+|(?:19|20)\d{2}|(?:FULL\W)?(?:(?:PRE)?CRACK(?:ED)?|ISO\W)|DLC|\W(?:(?:\d+\W)?LANG|PC|GOG|RIP|INCL?)(?:\W|$)|\WHD|ADDON|Directors\WCut|\w+\WEdition|MULTi\W?\d+|Complete|Language|(?:ENGLISH|\WENG\W)|(?:CP\W)?REPACK|Proper|RELOADED|CODEX|Razor|Black Box|ALiAS|FLT|WaLMaRT|PLAZA|KaOs|RiTUEL|SKIDROW|FINAL|AMPED|MACOSX|FULL|3DM|UNLOCKED|\d(?:[.,]\d+)?GB|[|])(?:\s?[\])])?.*$)/i,
"console": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:\s?[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?\s?[|\])])\s?)*)(.{3,}?)()((?:[\[(]\s?)?(?:(?:RF[.\s]?)?XBOX\s?360|(?:RF[.\s]?)?XBOX|360|PSP|PSX|PS1|PS2|PS3|PS4|PSN|\W[3n]\s?DS|\WDS|SNES|WII|WIIU|GAMECUBE|NTSC|PAL|USA|EUR|EU|MULTi11|REPACK|DLC|\WHD|PROPER|Ultimate\W(?:\w+\b\W)?Edition|Complete Edition|\d(?:[.,]\d+)?GB)(?!\w)(?:\s?[\])])?.*$)/i,
"console_type": /(?:XBOX\s?360|XBOX|PSP|PS2|PS3|PS4|3\s?DS|DS|WII|WIIU|GAMECUBE)/i,
"apps": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:\s?[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?\s?[|\])])\s?)*)(.*?)()((?:(?:V?\d+\.(?:\d+\.?[a-z]?)+)?\W(?:V|PATCH|BUILD|UPDATE|ALPHA|BETA)\W?\V?[(\[]?(?:\d+\.?)|\d+\.(?:\d+\.?[a-z]?)+|Multilanguage|untouched|32\W64\W?bit|(?:64|32)b(?:it)?|WIN\W?(?:64|32)|WIN64\W32|WIN32\W64|x86|x64|[(\[]).*$)/i,
"default": /^((?:[|\[(]?(?:\w{2,5}(?:\.\w{2,3})?(?:\s?[\s\+|\/-]+(?:\w{2,5}(?:\.\w{2,3})?|\d+))*\+?\s?[|\])])\s?)*)(.*$)()()/i
},
CSS = ".userDescription{float: right;text-align: right;color: #536482;margin: 2px 7px 2px 0;word-spacing: -2px;}" +
".generalDescription{margin-top: 2px;}" +
".season,.episode,.genInfo{font-weight:bold;}" +
".tvDescription{margin-left:5px;}" +
//".list-rows .pagination{position: absolute!important;}" +
".fileHost {float: right;margin-right: 2px;}" +
".altHost {text-align: center;font-weight: bold; overflow: hidden;background-image: url(http://s23.postimg.org/b8lsdn453/Not_Listed_2.png);background-size: cover;}" +
".list-rows .rating,.list-rows .genre {color: #536482;font-weight: bold;font-family: 'Lucida Grande', Verdana, Helvetica, Arial, sans-serif; border-bottom: 1px #E3E9F0 solid;border-right: 1px #E3E9F0 solid; text-align: center;background-color: #EDF1F5; vertical-align: middle;font-size: 10px;}" +
".rating{width:6%}" +
".ratVal{font-size:larger;display:none}" +
".ratVotes{font-weight: normal;display:none;}" +
".genre {width:15%;word-spacing: -3px}" +
".genre a{display:none;}" +
".topicrow:hover .rating,.topicrow:hover .genre{background-color: #F4F6F9;}";
$.expr[":"].containsI = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().trim()
.replace(/\s\([IVX]+\)\s/," ")
.replace(/the\b|part(?=\s?\d)/ig,"")
.replace(/\sII(?:\s|$)/g,"2")
.replace(/\sIII(?:\s|$)/g,"3")
.replace(/\sIV(?:\s|$)/g,"4")
.replace(/\sV(?:\s|$)/g,"5")
.replace(/\sVI(?:\s|$)/g,"6")
.replace(/\sVII(?:\s|$)/g,"7")
.replace(/\sIIX(?:\s|$)/g,"8")
.replace(/\sIX(?:\s|$)/g,"9")
.replace(/\sX(?:\s|$)/g,"10")
.replace(/and/ig,"&")
.replace(/äàâ/ig,"A")
.replace(/ç/ig,"C")
.replace(/éèëê/ig,"E")
.replace(/\W/g,"")
.toUpperCase()
.indexOf(arg.trim().replace(/the\b|part(?=\s?\d)|p(?=\d)|3d/ig,"")
.replace(/\sII(?:\s|$)/g,"2")
.replace(/\sIII(?:\s|$)/g,"3")
.replace(/\sIV(?:\s|$)/g,"4")
.replace(/\sV(?:\s|$)/g,"5")
.replace(/\sVI(?:\s|$)/g,"6")
.replace(/\sVII(?:\s|$)/g,"7")
.replace(/\sIIX(?:\s|$)/g,"8")
.replace(/\sIX(?:\s|$)/g,"9")
.replace(/\sX(?:\s|$)/g,"10")
.replace(/and/ig,"&")
.replace(/äàâ/ig,"A")
.replace(/ç/ig,"C")
.replace(/éèëê/ig,"E")
.replace(/\W/g,"")
.toUpperCase()) >= 0;
};
});
GM_addStyle(CSS);
if(document.URL.search(/viewforum.php\?f=4(?:&|$)|movies-f12/) > 0) forumSection = 'movies';
if(document.URL.search(/viewforum.php\?f=57(?:&|$)/) > 0) forumSection = 'tv';
if(document.URL.search(/viewforum.php\?f=5(?:&|$)/) > 0) forumSection = 'games';
if(document.URL.search(/viewforum.php\?f=28(?:&|$)/) > 0) forumSection = 'console';
if(document.URL.search(/viewforum.php\?f=3(?:&|$)|applications-f9/) > 0) forumSection = 'apps';
if(!forumSection) forumSection = 'default';
getJSON("http://pastebin.com/raw.php?i=yCwfr43g",init);
//THIS IS TO SEE HOW MANY USERS INTALLED THE SCRIPT
(function(){
var FR = GM_getValue("WBB-CU-FirstRun",1);
if(FR === 1 ){
GM_xmlhttpRequest({
method: "GET",
url: "http://pastebin.com/raw.php?i=HnumG4Qs",
onload: function(response) {
if(response.responseText === "Dummie"){
GM_setValue("WBB-CU-FirstRun",0);
}
}
});
}
})();
//THIS IS FOR GETTING THE IMDB INFORMATION FOR MOVIE AND TV SHOWS
var IMDB = function(title, year, item,retry) {
//console.log("WBB-CU:","IMDB Search",title,year,item)
retry = retry || false;
(function() {
GM_xmlhttpRequest({
method: "GET",
url: "http://akas.imdb.com/find?ref_=nv_sr_fn&s=tt&q=" + title + ((forumSection === "tv")? "&ttype=tv":"&ttype=ft"),
onload: function(response) {
if (response.status == 200) {
if (!/<a name="tt"><\/a>[\w\W]+?<\/table>/i.test(response.responseText)) {
if (/No results found for/.test(response.responseText)) {
console.log("IMDB_Search: No result found for:", title, year);
} else {
console.log("IMDB_Search: A unknown error has occured:", title, year);
}
return;
}
var responseData = response.responseText.match(/<a name="tt"><\/a>[\w\W]+?<\/table>/i)[0]
.replace(/(<img[\w\W]+?src=)"[^"]+"/g, '$1""'),
selector = {
"movies" :'.findResult:containsI("' + title + '"):not(:containsI("(video game)"),:containsI("(tv episode)"),:containsI("(tv series)"),:containsI("(tv mini-series)"),:containsI("(short)"))',
"tv":'.findResult:containsI("' + title + '"):containsI("(TV Series)"),.findResult:containsI("' + title + '"):containsI("(tv series)"),.findResult:containsI("' + title + '"):containsI("(tv mini-series)")',
"console": '.findResult:containsI("' + title + '"):containsI("(Video Game)")'
},
result = {
"Title": "",
"URL": ""
},
results = $(selector[forumSection], responseData);
if (results.length > 0) {
if (results.length > 1) {
if (year) {
if (results.find(":contains('" + year + "')").length === 0) {
if (results.find(":contains('" + (parseInt(year) - 1) + "')").length === 0) {
results = results.find(":contains('" + (parseInt(year) + 1) + "')");
}else{
results = results.find(":contains('" + (parseInt(year) - 1).toString() + "')");
}
} else {
results = results.find(":contains('" + year + "')");
}
}
if (results.length > 0) {
$('small',results[0]).remove();
result.Title = $(results[0]).text().trim();
result.URL = $(results[0]).find("a").attr("href").replace(/(.+)?\?.+$/, "http://imdb.com$1");
GetInfo(result, item);
} else {
console.log("IMDB_Search: ", "Found no match with the given query and year:", title, year);
}
} else {
$('small',results[0]).remove();
result.Title = $(results[0]).text().trim();
result.URL = $(results[0]).find("a").attr("href").replace(/(.+)?\?.+$/, "http://imdb.com$1");
GetInfo(result, item);
}
} else {
if ($('.findResult', responseData).length === 1) {
results = $('.findResult', responseData);
$('small',results[0]).remove();
result.Title = $(results[0]).text().trim();
result.URL = $(results[0]).find("a").attr("href").replace(/(.+)?\?.+$/, "http://imdb.com$1");
GetInfo(result, item);
} else {
if(forumSection === 'movies' && retry === false && /[\[(][^\])]+[\])]/.test(title)){
IMDB(title.replace(/[\[(][^\])]+[\])]/,""), year, item,true);
}else{
console.log("IMDB_Search: ", "Found no match with the given query:", title, year);
}
}
}
} else {
console.log(response.status + " " + response.statusText);
}
}
});
})();
var GetInfo = function(result, item) {
GM_xmlhttpRequest({
method: "GET",
url: result.URL,
onload: function(response) {
if (response.status == 200) {
var responseData = response.responseText.match(/<div id="title-overview-widget">[\w\W]+?<\/tbody>[\w\W]+?<\/table>[\w\W]+?<\/div>/i)[0]
.replace(/(<img[\w\W]+?src=)"[^"]+"/g, '$1""'),
Info = {
"Title": result.Title,
"Rating": "",
"Count": "",
"Genre": "",
"URL": result.URL,
"ID": result.URL.match(/tt\d+/)[0]
},
logged = /nblogout/.test(response.responseText);
Info.Rating = $('span[itemprop="ratingValue"]', responseData).text();
Info.Count = $('span[itemprop="ratingCount"]', responseData).text();
$('span[itemprop="genre"]', responseData).each(function() {
if (Info.Genre !== "") {
Info.Genre += " | ";
}
Info.Genre += $(this).text();
});
setIMDB(Info, item);
if(logged)inWatchList(Info.ID,item);
}
}
});
};
var inWatchList = function (MovieID,item){
GM_xmlhttpRequest({
method: "POST",
url: "http://www.imdb.com/list/_ajax/watchlist_has",
data: "consts%5B%5D=" + MovieID + "&tracking_tag=wlb-lite",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
onload: function(response) {
if(response.status == 200){
var obj = JSON.parse(response.responseText);
if(obj.status === 200){
if(typeof(obj.has[MovieID]) !== "undefined"){
$(".REGEX2,.REGEX3",item).css("color","#beab2a");
}
}else{
console.log("WBB-CU: IMDB: inWatchList: Status: " + obj.status) ;
}
}
}
});
};
var setIMDB = function(Info, item) {
if(!testing){
Info.Title = Info.Title.replace(/\s\([IVX]+\)\s/," ");
if(forumSection === "movies"){
$(".REGEX2",item).html(Info.Title.replace(/\((?:19|20)\d{2}\)/i,""));
}else if(forumSection === "tv"){
$(".REGEX2",item).html(Info.Title.replace(/\(TV Series\)/i,"").replace(/\(TV([^)]\))/i,"($1"));
}
}
if(parseInt(Info.Rating) > 0 ){
$(".rating .ratVal", item).html(Info.Rating.replace(".", ","))
.fadeIn(1000);
$(".rating .ratVotes", item).html(Info.Count + " Votes");
}
$(".genre a", item).html(Info.Genre.replace(/,\s/g, "|"))
.attr("href",Info.URL)
.fadeIn(1000);
};
};
//THIS IS FOR GETTING THE IGN INFORMATION FOR GAMES
var IGN = function(title,platform,item){
(function() {
GM_xmlhttpRequest({
method: "GET",
url: "http://www.ign.com/search?type=object&objectType=game&filter=games&q=" + title ,
onload: function(response) {
if(response.status === 200){
if (!/<div id="search-list"[\w\W]+?<!-- Ad.leaderboard -->/i.test(response.responseText)) {
if (/ Your search returned no matches./.test(response.responseText)) {
console.log("IGN_Search: No result found for:", title);
} else {
console.log("IGN_Search: A unknown error has occured:", title);
}
console.log('IGN_Search: Retrying search on GameSpot');
GameSpot(title,item);
return;
}
var responseData = response.responseText.match(/<div id="search-list"[\w\W]+?<!-- Ad.leaderboard -->/i)[0]
.replace(/(<img[\w\W]+?src=)"[^"]+"/g, '$1""'),
result = {
"Title": "",
"URL": ""
},
results = $(".search-item-title a:containsI('" + title +"')", responseData);
if (results.length > 0) {
result.Title = $(results[0]).text().trim();
if(platform && $(results[0]).parents(".search-item").find(".search-item-sub-title a:containsI('>" + platform + "<'):gt(0)").length > 0){
results = $(results[0]).parents(".search-item").find(".search-item-sub-title a:containsI('>" + platform + "<'):gt(0)");
}
result.URL = $(results[0]).attr("href");
GetInfo(result,item);
}else{
console.log("IGN_Search: Found no match with the given query: ", title);
console.log('IGN_Search: Retrying search on GameSpot');
GameSpot(title,item);
}
}
}
});
})();
var GetInfo = function(result, item) {
GM_xmlhttpRequest({
method: "GET",
url: result.URL,
onload: function(response) {
if (response.status == 200) {
var responseData = response.responseText//.match(/<div id="object-stats-wrap"[\w\W]+?<\/div>\W+(?:<\/aside>)/i)[0]
.replace(/(<img[\w\W]+?src=)"[^"]+"/g, '$1""'),
year = $('.gameInfo-list div:contains("Date")',responseData).text().match(/\d{4}/),
Info = {
"Title": result.Title + ((year === null) ? "" : " (" + year[0] + ")"),
"Rating": "",
"Count": "",
"Genre": "",
"URL": result.URL,
};
if($('.communityRating .ratingValue',responseData).length > 0 ) {
Info.Rating = $(".communityRating .ratingValue",responseData)
.text()
.trim()
.replace('-.-','N/A');
}
if($('.communityRating .ratingCount',responseData).length > 0 ){
Info.Count = $(".communityRating .ratingCount",responseData)
.text()
.trim()
.match(/\d+/)[0];
}
if($(".gameInfo-list [href^='/games/editors-choice?genre=']",responseData).length > 0 ){
Info.Genre = $('.gameInfo-list div:contains("Genre")',responseData)
.text()
.replace(/\n|genre:|\s{2,}/ig," ")
.trim();
}
setIGN(Info, item);
}
}
});
};
var setIGN = function(Info, item) {
if(!testing){
$(".REGEX2",item).html(Info.Title);
}
if(parseInt(Info.Rating) > 0 ){
$(".rating .ratVal", item).html(Info.Rating.replace(".", ","))
.fadeIn(1000);
$(".rating .ratVotes", item).html(Info.Count + " Votes");
}
$(".genre a", item).html(Info.Genre)
.attr("href",Info.URL)
.fadeIn(1000);
$(".genre", item).css("word-spacing","0px");
};
};
//THIS IS FOR GETTING THE GAMESPOT INFORMATION FOR GAMES
var GameSpot = function(title,item){
(function() {
GM_xmlhttpRequest({
method: "GET",
url: "http://www.gamespot.com/search/?indices%5B0%5D=game&q=" + title,
onload: function(response) {
if(response.status === 200){
if (!/<ul class="search-results[\w\W]+?<\/ul>/i.test(response.responseText)) {
if (/We couldn't find what you are looking for. Care to try again?/.test(response.responseText)) {
console.log("GameSpot_Search: No result found for:", title);
} else {
console.log("GameSpot_Search: A unknown error has occured:", title);
}
return;
}
var responseData = response.responseText.match(/<ul class="search-results[\w\W]+?<\/ul>/i)[0]
.replace(/(<img[\w\W]+?src=\W?)"[^"]+"/g, '$1""'),
result = {
"Title": "",
"URL": ""
},
results = $(".media a:containsI(" + title +")", responseData);
if (results.length > 0) {
result.Title = $(results[0]).text().trim();
result.URL = "http://www.gamespot.com" + $(results[0]).attr("href");
GetInfo(result,item);
}else{
console.log("GameSpot_Search: ", "Found no match with the given query:", title);
}
}
}
});
})();
var GetInfo = function(result, item) {
GM_xmlhttpRequest({
method: "GET",
url: result.URL,
onload: function(response) {
if (response.status == 200) {
var responseData = response.responseText.match(/<div id="object-stats-wrap"[\w\W]+?<\/div>\W+(?:<\/aside>)/i)[0]
.replace(/(<img[\w\W]+?src=\W?)"[^"]+"/g, '$1""'),
year = $('.pod-objectStats-info__release',responseData).text().match(/\d{4}/),
Info = {
"Title": result.Title + ((year === null) ? "" : " (" + year[0] + ")"),
"Rating": "",
"Count": "",
"Genre": "",
"URL": result.URL,
};
Info.Rating = $(".breakdown-reviewScores__userAvg a",responseData).text().replace('0','');
Info.Count = $(".breakdown-reviewScores__userAvg dd",responseData).text().match(/\d+/)[0].replace('0','');
$(".pod-objectStats-additional [href^='/genre/']",responseData).each(function() {
if (Info.Genre !== "") {
Info.Genre += " | ";
}
Info.Genre += $(this).text();
});
setGameSpot(Info, item);
}
}
});
};
var setGameSpot = function(Info, item) {
if(!testing){
$(".REGEX2",item).html(Info.Title);
}
if(parseInt(Info.Rating) > 0 ){
$(".rating .ratVal", item).html(Info.Rating.replace(".", ","))
.fadeIn(1000);
$(".rating .ratVotes", item).html(Info.Count + " Votes");
}
$(".genre a", item).html(Info.Genre)
.attr("href",Info.URL)
.fadeIn(1000);
};
} ;
//IS CALLED AFTER GETTING THE HOSTS DATA
function init(data){
console.log("WBB-CU:","init");
fileHosts = data;
if(forumSection === "movies" || forumSection === "tv" || forumSection === "console" || forumSection === "games") reformat();
cleanTopicTitels($(".cat-row:last ~ .list-rows a.topictitle,.search-view ~ .list-wrap .list-rows .topictitle > a:last-child,.topiclist.topics:last .row dt a.topictitle,.forumline:eq(0) tr:gt(-51) a.topictitle"));
}
//IF WHE ARE IN THE MOVIES OR TV SHOW SECTION THEN REFORMAT THE LAYOUT TO ADD THE GENRE AND RATING
function reformat(){
var header = $(".list-header").clone(), timer;
$(".short-description",header).after('<div class="rating"><span>Rating</span></div><div class="genre"><span>Genre</span></div>');
$(".cat-row:last").css("display","none");
$(".cat-row:last").after(header);
$(".cat-row:last ~ .list-header .short-description").css("width","49%");
$(".cat-row:last ~ .list-header .topics,.cat-row:last ~ .list-header .views").css("width","5%");
$(".cat-row:last ~ .list-header .last-post").css("width","10%");
$(".cat-row:last ~ .list-rows .description").css("width","46%");
$(".cat-row:last ~ .list-rows .topics,.cat-row:last ~ .list-rows .views").css("width","5%");
$(".cat-row:last ~ .list-rows .last-post").css("width","10%");
$(".cat-row:last ~ .list-rows .description").after('<div class="rating"><div class="ratVal"></div><div class="ratVotes"></div></div><div class="genre"><a target="_blank"></a></div>');
$('.cat-row:last ~ .list-rows .topicrow').on({
'mouseover': function () {
timer = setTimeout(function (el) {
jQuery(el).find(".ratVotes").show("slow");
}, 300,this);
},
'mouseout' : function () {
clearTimeout(timer);
jQuery(this).find(".ratVotes").hide("fast");
}
});
}
//START CLEANING TOPIC TITLES
function cleanTopicTitels(list) {
//console.log("WBB-CU:","cleanTopicTitels:");
$(list).each(function() {
var curr = $(this).text(),
match,
parent = $($(this).parents(".list-rows,tr")[0]),
isCollection = false;
if (isTAG($(this).prev())) {
$(this).prev().prependTo(this);
}
if(forumSection === "console"){
match = curr.match(/^((?:[\[{(](?:[\w{2,5}.]+\b[\s+|\-\/\d]*)*[\]})]\s*)+)?((?:[\[(]\s?)?(?:XBOX\s?360|XBOX|PSP|PS2|PS3|PS4|3\s?DS|DS|WII|WIIU|GAMECUBE)(?:\s?[\])])?)/i);
if(match){
var con = match[2];
curr = curr.replace(con,"") + " " + con;
$(this).text(curr);
}
}
$(this).attr("title", curr);
if(!/collection|movies|games|ISO'?s|ROMS/i.test(curr)){
if(RegEX[forumSection].test(curr)){
match = curr.match(RegEX[forumSection]);
}else if(forumSection !== 'default'){
match = curr.match(RegEX['default']);
}
}else{
match = curr.match(RegEX['default']);
isCollection = true;
}
if (match) {
var colors = ["orange", "blue", "green", "darkmagenta"],
template = $('<span class=""></span>'),
rep;
for (i = 1; i < match.length; ++i) {
if (typeof match[i] !== "undefined" && match[i] !== " ") {
template.addClass('REGEX' + i);
if (testing) template.css({ "background-color": colors[i - 1],"color": "white"});
switch (i) {
case 2:
template.text((/\s/.test(match[i]) !== true) ? match[i].replace(/\./g, " ") : match[i]);
if(!/\s$/.test(template.text())) template.text(template.text() + " " );
break;
case 3:
template.text(/\((?:19|20)\d{2}(?:[-+](?:19|20)\d{2})?\)/.test(match[i]) ? match[i] : (/(?:19|20)\d{2}(?:[-+](?:19|20)\d{2})?/.test(match[i])) ? ("(" + match[i].match(/(?:19|20)\d{2}(?:[-+](?:19|20)\d{2})?/)[0] + ")") : match[i]);
break;
default:
template.text(match[i]);
break;
}
$(this).html(curr.replace(match[i].replace(/&(?!amp;)/g, "&"), template[0].outerHTML));
curr = $(this).html();
template = $('<span class=""></span>');
}
}
if(!/\s/.test(parent.find(".REGEX2").text().trim())){
var nospace = parent.find(".REGEX2");
nospace.text(nospace.text().replace(/\.|_/g," "));
}
if(!isCollection){
if(forumSection === "movies" || forumSection === "tv"){
var title = parent.find(".REGEX2").text()
.replace(/\sn\s|&/,'&')
.replace(/\[?(?:Unrated|Extended Cut|Extended|Collectors|Edition|Directors Cut)\]?/ig,''),
year = parent.find(".REGEX3").text().replace(/[()]/g,"");
IMDB(/\s/.test(title.trim()) ? title : title.replace(/\./g," "),year,parent);
}else if( forumSection === "console" || forumSection === "games"){
var title = parent.find(".REGEX2")
.text().trim()
.replace(/\sn\s|&/,'&')
.replace(/\[?(?:\W$)\]?/ig,''),
platforum;
if(forumSection === "console"){
platforum = parent.find(".REGEX4")
.text()
.match(RegEX.console_type);
}else{
platforum = "PC";
}
IGN(/\s/.test(title.trim()) ? title : title.replace(/\./g," "),platforum,parent);
}
}
}
parent = $(this).parents(".description,dl,.row1");
if ($("span:first:has(br),dt:first:has(br),span.gensmall:first:has(br)", parent).length > 0) {
var org = $(this).attr("title");
curr = $("span:first:has(br),dt:first:has(br),span.gensmall:first:has(br)", parent);
curr.html(curr.html().replace(/(<br>[^<]+)/, '<span id="userDescription">$1</span>'));
$(".title a",parent).attr("title", org + "\x0A" + $("#userDescription",curr).text());
}
setHostIcons($(parent.find(".REGEX1")));
setDescription($(parent.find(".REGEX4")));
});
if (!testing)$("span#userDescription,.REGEX4,.REGEX1").hide();
}
//SET THE DIFFERENT HOST ICON BASED ON TAG
function setHostIcons(item){
//console.log("WBB-CU:","setHostIcons");
var TAG = item.text().replace(/[\]\}]\s?[\[\{]/g,"|").replace(/[\[\](){}]|1LINK|1L/gi,"").toUpperCase().trim(),
size = 20,
HOSTS = removeDuplicates(TAG.split(/[/+|\s,\-]/)),
icon = "";
for(i = 0;i < HOSTS.length;i++){
if(fileHosts[HOSTS[i]]){
icon = $("<img src='" + fileHosts[HOSTS[i]].ico + "' title='" + fileHosts[HOSTS[i]].host + "'>");
icon.css({"height":size + "px"});
}else if(HOSTS[i].match(/^\d$/)){
icon = $("<span title='And " + HOSTS[i] + " more hosts!'>" + "+" + HOSTS[i] +"</span>");
icon.css({"height": size + "px","width": size + "px","font-size": size / 2 + "px","line-height": size + "px"});
icon.addClass("altHost");
}else{
icon = $("<span title='Not listed host.\nTAG:" + HOSTS[i] + "'>" + HOSTS[i] +"</span>");
icon.css({"height": size + "px","width": size + "px","font-size": size / 2 + "px","line-height": size + "px"});
icon.addClass("altHost");
}
if(icon){
icon.addClass("fileHost");
item.parent().after(icon);
}
}
}
//SET ALL THE DESCRIPTION BASED ON USERS GIVEN DATA
function setDescription(item) {
//console.log("WBB-CU:","setDescription");
var description = removeDuplicates((item.text() + " " + item.parents(".description,dl,.row1").find("#userDescription").text())
.replace(/(?:1|single)\s?links?[\S]?/ig,"1L")
.replace(/(\d+(?:[.,]\d+)?\s?(?:GB|MB))\WLINKS?/ig,function(a,b){return b.replace(/\./,",") + ",;,Links";})
.replace(/(\d+(?:[.,]\d+)?)\s?(GB|MB|CH)/ig,function(a,b,c){return b.replace(/\./,",") + c.toUpperCase();})
.replace(/DD5\.1/ig,"DD5,1")
.replace(/(web|dts|XBOX)[\-\s](dl|ONE|360)/ig,"$1,;,$2")
.replace(/(\d+),(\W?20\d{2})/ig,"$1-$2")
.replace(/(V?\d+[\-\s.]?(?:\d+[\-\s.]?)*\W)?((?:(?:BETA|ALPHA|BUILD|UPDATE)\W?V?|V)\W?)(\d+[\.\s\-]?(\d+[\.\s\-]?)*)/gi,function(a,b,c,d){
return ((typeof b === "undefined") ? '' : b.replace(/[.\-\s](\d+)/g,",$1")) + c.replace(/\W/g,",;,") + d.replace(/[.\-\s](\d+)/g,",$1");
})
.replace(/((?:[^V,]|^)\d+[\.\s\-](\d+[\.\s\-]?)*[a-z]?)(?=\W|$)/ig,function(a,b){
return b.replace(/\./g,",");
})
.replace(/((?:ULTIMATE[\s.])?\w+\b[\s.]EDITION)/ig,function(a){return a.trim().replace(/[\s.]/g,",;,");})
.replace(/(\d+)\WLANG(?:UAGE)?/ig,'MULTi$1')
.replace(/Blu\WEvo|AGB\WGolden\WTeam|@Dake\WAI|VT\WTeam\WSub|Black\WBox|M\WTeam|PxHD\Wmobies|PS3\WTeam/,function(a){return a.replace(/[\-\s]/g,",;,");})
.replace(/[=\/\+\-\[\]\(\)\/\.|_:]/g, " ")
.replace(/\s{2,}/g," ")
.replace(/,;,/g,"-").split(/\s/)),
container = {
"Source": [],
"Resolution":[],
"Size": [],
"Container": [],
"Video": [],
"Audio": [],
"Group": [],
"Console": [],
"Edition": [],
"Version": [],
"Update": [],
"Build": [],
"Extra": [],
},
parent = item.parents(".description,.row1"),
result = "";
parent.append("<div class='userDescription'></div>");
parent.find(".pagination").appendTo(parent);
for (var des in description) {
var value = description[des];
switch (true) {
case /^(?:dvd|dvdrip)$/i.test(value):
if(forumSection === "movies" || forumSection === "tv")
addInfo(container.Source, "DVD");
break;
case /^(?:dvdr|dvd5|dvd9)$/i.test(value):
if(forumSection === "movies" || forumSection === "tv")
addInfo(container.Source, "Full-DVD");
break;
case /^(?:bluray|brrip|bdrip|blu-ray|br)$/i.test(value):
if(forumSection === "movies" || forumSection === "tv")
addInfo(container.Source, "BluRay");
break;
case /^(?:hddvd)$/.test(value):
if(forumSection === "movies" || forumSection === "tv")
addInfo(container.Source, "HD-DVD");
break;
case /^(?:cam|camrip|hdcam)$/i.test(value):
if(forumSection === "movies" || forumSection === "tv")
addInfo(container.Source, "CAM");
break;
case /^(?:r[1-9])$/i.test(value):
addInfo(container.Source, description[des].toUpperCase());
break;
case /^(?:dvdscr|screener|scr)$/i.test(value):
addInfo(container.Source, "Screener");
break;
case /^(?:ts|hqts|telesync|hdts)$/i.test(value):
addInfo(container.Source, "TeleSync");
break;
case /^(?:tc|telecine)$/i.test(value):
addInfo(container.Source, "TeleCine");
break;
case /^(?:wp|workprint)$/i.test(value):
addInfo(container.Source, "WorkPrint");
break;
case /^(?:web-?dl|web)$/i.test(value):
addInfo(container.Source, "WEB-DL");
break;
case /^(?:web-?rip)$/i.test(value):
addInfo(container.Source, "WEB-RIP");
break;
case /^(?:web-?cap)$/i.test(value):
addInfo(container.Source, "WEB-CAP");
break;
case /^(?:hdrip|hdtv)$/i.test(value):
addInfo(container.Source, "HDTV");
break;
case /^(?:PPV|PPVRip)$/i.test(value):
addInfo(container.Source, "PPV");
break;
case /^(?:VODRip|VODR)$/i.test(value):
addInfo(container.Source, "VOD");
break;
case /^(?:360p|480p|576p|720p|1080p)$/i.test(value):
addInfo(container.Resolution, description[des].toLowerCase());
break;
case /^(?:x264|h264|x265|h265|hevc|dvix|xvid)$/i.test(value):
addInfo(container.Video, description[des].toUpperCase());
break;
case /^(?:avi|mp4|mkv|asf|flv|f4v)$/i.test(value):
addInfo(container.Container, description[des].toUpperCase());
break;
case /^(?:\d(?:,\d)?ch|dd5,1|dts-hd|dts|aac|ac3)$/i.test(value):
addInfo(container.Audio, description[des].toUpperCase().replace(/,/,"."));
break;
case /^(?:\d+(?:,\d+)?(?:mb|gb))$/i.test(value):
addInfo(container.Size, description[des].toUpperCase().replace(/,/,"."));
break;
case /UPDATE-V?(\d+(?:.\d+)*)/i.test(value):
addInfo(container.Update,
description[des].replace(/,/g,".")
.replace(/UPDATE-|v/ig,""));
break;
case /BUILD-V?(\d+(?:.\d+)*)/i.test(value):
addInfo(container.Build,
description[des].replace(/,/g,".")
.replace(/BUILD-|v/ig,""));
break;
case /^V?-?(\d+,(?!$)(\d+,?)*[a-z]?)$/i.test(value):
if(forumSection === "games" || forumSection === "apps" || forumSection === "console" )
addInfo(container.Version,
description[des].replace(/,/g,".")
.replace(/v-?/i,""));
break;
case /^(?:V\d+)$/i.test(value):
addInfo(container.Version, "v" +
description[des].replace(/,/g,".")
.replace(/v/i,""));
break;
case /Edition$/i.test(value):
addInfo(container.Edition,description[des].replace(/-Edition/g,"")
.replace(/-/," "));
break;
case /^(?:XBOX-?ONE|XBOX|PS4|PS3|PS2|PSP|3DS|NDS|SNES|NES|WII?-U|WII|GAMECUBE|Dreamcast)$/i.test(value):
addInfo(container.Console, description[des].toUpperCase());
break;
case /^(?:PS1|PSX)$/i.test(value):
addInfo(container.Console, "PS1");
break;
case /^(?:XBOX-?360|X-?360)$/i.test(value):
addInfo(container.Console, "XBOX360");
break;
case /^(?:KaOs|GOG|Blu-Evo|AGB-Golden-Team|@Dake-AI|VT-Team-Sub|Black-Box|M-Team|PxHD-mobies|PS3-Team|FAS|3DM|ALI213|BiTE|CORE|Unleashed|PROPHET|RELOADED|CODEX|Razor|ALiAS|FLT|WaLMaRT|PLAZA|RiTUEL|SKIDROW|Mikas|BHRG|TiTAN|RLSM|RAV3N|NODLABS|RARBG|m2g|GAC|LiGHTFOR|Nocturnal|MARVEL|PLAYASiA|PSFR33|GLoBAL|SPARE|APATHY|STRANGE|DNL|Allstars|CONTRAST|PUSSYCAT|P2P|IPT|VENOM|iMARS|PROTOCOL|COMPLEX|ANTiDOTE|DUPLEX|UNLiMiTED|ACCiDENT|iND|ABSTRAKT|CLANDESTiNE|PSA|PHOBOS|3DT|PRoDJi|TLF|de[42]|decibeL|D-Z0N3|FoRM|FTW-HD|G3N3|HiFi|INtL|McXode|Penumbra|PUDDiNG|SaNcTi|Positive|BDbits|FraMeSToR|ALeSiO|FASM|NiBuRu|LoNeWolf|FLAWL3SS|HDxT|PrimeHD|Grond|MarGe|BluHD|3DNORD|RealHD|jack|RUXI|JEM|NTb|HiSD|CHD|CHDTV|CHDBits|CHD3D|CHDPAD|AREA11|HDTime|beAst|HDRemuX|TBH|3DV|playHD|playTV|playMUSIC|playON|playXD|playMB|FiLELiST|TvT|HDBrise|mkvrg|SpaceHD|RiplleyHD|RightSiZE|KM|Mikemelo1369|aZA|HDSTaRS|Gh0st|HiDt|ViSTA|HDMaNiAcS|BluDragon|KRaLiMaRKo|iMN|HiDe|HDViE|YoHo|HDC|NoVA|HDCITY|0DAY|CMCT|@GGZLI|MiniBD1080P|iCandy|HDMEvolution|MobileHD|FourGHD|ReMuXmE|MeRCuRY|DGN|HDL|ASUT|CwP|EbP|EPiK|Hanoi|HDAT|HDNews|HDO|Subits|L2Bits|SDvB|MySilu|HDROAD|HDS|HDSTAR|HDSPAD|HDWing|HDWTV|iHD|HDChina|kishd|FooKaS|Q0S|LTRG|KiSHD|BMDru|HDStar|OpenCD|LLM|KHQ|PxHD|PxEHD|Px3D|bxEHD|SKALiWAGZ|TBB|HANDJOB|CrEwSaDe|CtrlSD|SaM|Skullz|HaB|Wiki|NGB|BDClub|OoKU|TRiM|IVT|VTBT|VTMT|XTSF|DiRTY|ViKAT|Bunny|Chotab|VaAr3|Soul|Nero9|Green|JENC|tRuEHD|IJR|REVEiLLE|FUM|mSD|NhaNc3|MkvCage|VTMT(C)Z|AE|AJ8|AJP|Arucard|AW|BBW|BG|BoK|CRiSC|Crow|CtrlHD|D4|DiGG|DiR|disc|DBO|DON|DoNOLi|ESiR|ETH|fLAMEhd|FPG|FSK|Ft4U|fty|Funner|GMoRK|GoLDSToNE|H2|h264iRMU|HDB|HDBiRD|H@M|hymen|HZ|iLL|IMDTHS|iNFLiKTED|iOZO|J4F|JAVLiU|JCH|k2|KTN|KweeK|lulz|M794|MAGiC|MCR|MdM|MMI|Mojo|NaRB|NiX|NWO|OAS|ONYX|PerfectionHD|PHiN|PiNG|Prestige|Prime|PXE|QDP|QXE|Redµx|REPTiLE|RuDE|S26|sJR|SK|SLO|SPeSHaL|SrS|Thora|tK|TM|toho|TSE|VanRay|ViNYL|XSHD|YanY|Z|Zim'D|FGT|NoGRP|C4TV|CHAMPiONS|2HD|LOL|ASAP|KILLERS|DIMENSION|MixedPack|JIVE|AFG|kingdom|viethd|nCore|HDA|hijacked|anoXmous|SANTi|fanta|ind|ozlem|redblade|psychd|playnow|resurrection|cybermen|juggs|highcode|imp3ria|sinners|rarbg|budyzer|fico|ift|legion|evo|amiable|melite|ink|ebp|mchd|hdaccess|sparks|cadaver|fragment|jyk|rovers|lost|wiki|an0nym0us|ltu|taste|covziro|bipolar|rusted|brmp|blackjesus|geckos|tayto|hidt|sonido|majestic|nohate|alliance|kaka|yify|noscreens|shaanig|fwolf|eve|sadpanda|blitzcrieg|axxo|viznu)$/i.test(value):
addInfo(container.Group, description[des]);
break;
case /^(?:\d+(?:,\d+)?(?:mb|gb)-LINKS\W?)$/i.test(value):
addInfo(container.Extra,description[des].replace(/-/," ")
.replace(/\W$/,""));
break;
case /^(?:1L|EUR|USA|PAL|NTSC|RETAIL|MULTI\d+|REMASTERD|HD|PreCracked|REPACK|DLCs?|MacOSX?|CRACK|KEYGEN|SERIAL|PATCH|Portable|Cracked|SP\d)$/i.test(value):
addInfo(container.Extra,description[des]);
break;
}
}
for (var TAG in container) {
if (container[TAG].length > 0) {
if (result !== "") result += " | ";
result += "<span class='TAG'>" + TAG + ": </span>" + "<span class='genInfo'>" + container[TAG].join("<span style='font-weight:normal'> - </span>") + "</span>";
}
}
if (result !== "")$('.userDescription',parent).append("<div class='generalDescription'>" + result + "</div>");
if(forumSection === "tv"){
var season,episode,match;
if(RegEX.episode.test(item.text())){
match = item.text().match(RegEX.episode);
console.log(item.text(),match);
if(!RegEX.season.test(item.text())){
try {
season = "<span class='TAG'>Season: </span><span class='season'>" +
match[0].trim()
.match(/S(?:eason\s?)?\d{1,2}|\d{1,2}x/)[0]
.replace(/[^\d]*(\d+)x?/,"$1")
.replace(/^(\d$)/,"0$1") + "</span>";
}catch(err) {
console.log('WBB-CU:','TV:',item.text(),err);
}
}
episode = "<span class='TAG'>Episode: </span><span class='episode'>" +
match[0].trim()
.replace(/season\s\d{1,2}.?\sepisode\s(\d{1,2})/i,"$1")
.replace(/(?:S\d+-?)?E(\d+)[\s\-]E?(\d+)/i,"$1 <span style='font-weight:normal'> To </span> $2")
.replace(/\d{1,2}x(\d{1,2})/,"$1")
.replace(/.+E(\d{1,2})/,"$1")
.replace(/(?:^|E)(\d)$/,"0$1") + "</span>";
$('.userDescription',parent).prepend("<span class='tvDescription'>" + episode + "</span>");
if(season)$('.userDescription',parent).prepend("<span class='tvDescription'>" + season + "</span>");
}
if(RegEX.season.test(item.text())){
match = item.text().match(RegEX.season);
var seasons = match[1].split("-");
season = "<span class='TAG'>Season: </span><span class='season'>";
if(seasons.length > 1){
season += seasons[0].match(/\d{1,2}$/g)[0]
.replace(/^(\d)$/,"0$1") + "<span style='font-weight:normal'> To </span>" +
seasons[seasons.length-1].match(/\d{1,2}$/g)[0]
.replace(/^(\d)$/,"0$1")+ "</span>";
}else{
season += seasons[0].match(/\d+/g)[0].replace(/^(\d)$/,"0$1")+ "</span>";
}
$('.userDescription',parent).prepend("<span class='tvDescription'>" + season + "</span>");
}
}
}
function addInfo(Array,Info){
if(Array.indexOf(Info) === -1)Array.push(Info);
}
function removeDuplicates(Array){
return Array.filter(function(item, pos) {
return ((item !== undefined && item !== "") ? Array.indexOf(item) == pos : null );
});
}
function isTAG(element){
return /((?:(?=\[|\w)\[?(?:\b\w{2,5}\b[+|\-\/\d]*)*\])+)/.test($(element).text());
}
//GETTING THE DIFFERENT HOSTS DATA
function getJSON(url,callback){
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {'Content-Type':'application/x-www-form-urlencoded'},
onload: function(response) {
if(response.status == 200){
callback(JSON.parse(response.responseText));
}else{
console.log(response.status + " " + response.statusText);
}
}
});
}