// ==UserScript==
// @name WLR for IE & Opera
// @namespace http://forums.whirlpool.net.au
// @version 0.1
// @description A port to IE & Opera of Meat Sack's WLR script
// @include http://forums.whirlpool.net.au/*
// @exclude http://forums.whirlpool.net.au/forum-replies.cfm?*p=-2*
// ==/UserScript==
/**important to do**/
//set up otions page to turn on/off features
//put the smack-down on Bravo
/**not important to do**/
//add wiki autolinks
//contact is now online
//common phrases
//delicious tagger?
/*function bugga(bugsName,bugsValue){
if($('#hideShow')[0] === undefined){
$('body').prepend('
Bugga:
');
}
var tempHoldDebug = $('#debugDiv').html();
$('#debugDiv').html(tempHoldDebug+"
';
/*******whirlcode buttons event handler********/
function doStuffToTheText(theTextBox){
$('.wcodeButtons').mouseup(function(){
var buttonID = $(this).attr('id');
var currentValue = theTextBox.value;
var theSelection = document.selection.createRange().text;
theTextBox.focus();
if(theSelection === ""){
if(buttonID == "wc_whirlurl"){
document.selection.createRange().text = '&<#^';
$('body').prepend('
'+
'
Enter link address:
'+
'
');
$('body').prepend('
'+
'
Enter link title:
'+
'
');
$('.cancel').mouseup(function(){
$('#modal,#modal2').remove();
$('#body')[0].value = $('#body')[0].value.replace("&<#^","");
theTextBox.focus();
});
setTimeout("$('#urlAddress').focus();", 5);
var urlAdd;
$('#ok')[0].onmouseup = firstOK;
$('#urlAddress')[0].onkeyup = function (evt) {
if (!evt) {
evt = window.event;
}
if(evt.keyCode == 13){
firstOK();
}
};
function firstOK(){
if ($('#urlAddress')[0].value !== ""){
urlAdd = $('#urlAddress')[0].value;
$('#modal').remove();
setTimeout("$('#urlName').focus();", 5);
}
}
$('#ok2')[0].onmouseup = secondOk;
$('#urlName')[0].onkeyup = function (evt) {
if (!evt) {
evt = window.event;
}
if(evt.keyCode == 13){
secondOk();
}
};
function secondOk(){
if ($('#urlName')[0].value !== ""){
var urlN = $('#urlName')[0].value;
$('#modal2').remove();
if(urlAdd.indexOf('http') < 0){
$('#body')[0].value = $('#body')[0].value.replace('&<#^',''+urlN+'');
}
else{
$('#body')[0].value = $('#body')[0].value.replace('&<#^',''+urlN+'');
}
}
}
}
else if(((currentValue.split(whirlCode[buttonID].encloseLeft).length+currentValue.split(whirlCode[buttonID].encloseRight).length) % 2) === 0){
document.selection.createRange().text = whirlCode[buttonID].encloseLeft;
}
else{
document.selection.createRange().text = whirlCode[buttonID].encloseRight;
}
}
else if((theSelection !== "") && (buttonID != 'wc_whirlurl')){
document.selection.createRange().text = whirlCode[buttonID].encloseLeft + theSelection + whirlCode[buttonID].encloseRight;
}
theTextBox.focus();
theSelection = '';
});
}
var lrl;
if(document.cookie.indexOf('wlrcookie') > -1){
var docCookArray = document.cookie.split('; ');
var wlrCookArray = [];
for(ca=0;ca -1){
var cookieSplit = docCookArray[ca].split('wlrcookie=')[1];
wlrCookArray.unshift(cookieSplit); //so oldest cookie is at end
}
}
var wlrCookArrayString = wlrCookArray.toString().replace(/,/,"");
var arr;
var regexCheat = wlrCookArrayString+"t%3D";
}
/*******run on forum-threads.cfm page********/
/****Cookies & Last Read Function on forum-threads.cfm page*****/
if((document.URL.indexOf('threads') > -1) || (document.URL.indexOf('user') > -1)){
$('td[@width=23] a').each(function(){
var bottomLinkParent = $(this).parent();
var cutHref = this.href.slice(this.href.indexOf('t=')+2,this.href.indexOf('&p=-1#bottom'));
if(wlrCookArrayString.indexOf(cutHref) > -1){
bottomLinkParent.clone().css({opacity: "0.4"}).insertAfter(bottomLinkParent);
var getLastRead = regexCheat.slice(regexCheat.indexOf(cutHref), regexCheat.indexOf('t%3D', regexCheat.indexOf(cutHref)));
this.href = this.href.replace("&p=-1#bottom","").replace(""+cutHref+"", ""+decodeURIComponent(getLastRead)+"");
//bugga('this.href.replace("&p=-1#bottom","").replace(""+cutHref+"", ""+decodeURIComponent(getLastRead)+""); ',this.href.replace("&p=-1#bottom","").replace(""+cutHref+"", ""+decodeURIComponent(getLastRead)+""));
bottomLinkParent.css({background:"#DDDDDD url(http://img.photobucket.com/albums/v215/thegooddale/red-ltgrey.gif) repeat scroll 0%"});
$(this).children('img').attr('alt','Jump to last read post in thread');
}
});
} ///end Cookies & Last Read Function on forum-threads.cfm page
/*******run on forum-replies page********/
if (document.URL.indexOf('replies') > -1) {
var threadNoCheck = $('a').contains('First post')[0].href.replace("&p=-1","");
var threadNumberWc;
if (threadNoCheck.indexOf('#') > -1){
threadNumberWc = threadNoCheck.slice(threadNoCheck.indexOf('t=')+2, threadNoCheck.indexOf('#'));
}
else{
threadNumberWc = threadNoCheck.split('t=')[1];
}
var replyLink = $('.breadtask a:first')[0].href;
/****Avatars*****/
var lnk = document.createElement('LINK');
lnk.rel = 'stylesheet';
lnk.type = 'text/css';
lnk.href = 'http://ideatriage.com/wlr/avatar/avatar.css';
document.getElementsByTagName( 'HEAD' )[0].appendChild( lnk );
$("td[@class^=bodyuser]").each(function(){
$(this).children('a:first').wrap(''); //temp fix so the div:first-child in the WLR CSS works
var tempLinkuserId = $(this).children('div:eq(2)').children('a:first')[0].href;
var prunedId = tempLinkuserId.slice(tempLinkuserId.indexOf('id=')+3);
$(this).parent().addClass('wlr_'+prunedId);
});
if (replyLink.indexOf("print") === -1){ //check if thread is closed
$('.greylink:even').after(' | q-quote');
/*******insert the quick quote text box********/
$('#replies').after('
' +
'' +
'
');
/***event handlers for Preview & Clear Buttons***/
var getOnce = $('#body');
var theTextBox = getOnce[0];
$('#prev').mouseup(function(){
this.value = 'Please wait...';
return true;
});
$('#clearText').mouseup(function(){
theTextBox.value = "";
theTextBox.focus();
return false;
});
/***quick quote function***/
$('.qquoteie').click(function(){
var theClick = $(this);
var txt = document.selection.createRange().text;
var getLink = theClick.prev().prev().attr("href");
var getPostId = getLink.slice(getLink.indexOf("r=")+2, getLink.indexOf("&tp"));
var getUserName = theClick.parent().parent().prev().prev().find('.bu_name').text();
var writesID = "[+"+getPostId+" "+getUserName+" writes... +]\n";
var writesText = '["'+txt+'"]\n\n';
var anyTextInBox = theTextBox.value;
if (anyTextInBox !== ""){
theTextBox.value = anyTextInBox+"\n"+writesID+writesText;
}
else{
theTextBox.value = writesID+writesText;
}
window.scrollBy(0, 999999999);
theTextBox.focus();
return false;
});
getOnce.css("width","70%");
doStuffToTheText(theTextBox);
}
/****Cookies & Last Read Function on forum-replies page*****/
var anchorAray = [];
var hrefArray = [];
function getY( element, linkHref ){
var iReturnValue = 0;
iReturnValue += element.offsetTop;
element = element.offsetParent;
iReturnValue += element.offsetTop;
anchorAray.push(iReturnValue);
hrefArray.push(linkHref);
}
$('a[@title$=specific post]').each(function(){
getY(this, this.href);
});
var largestScrollY = 1;
window.onscroll = function() {
if (document.documentElement.scrollTop > largestScrollY){ //change to window.pageYOffset if need to get it to work in FF
largestScrollY = document.documentElement.scrollTop;
}
};
function writeToCookie(lrl){
function putStringArrayBackToCookie(lrl ,arr) {
var w = 0;
var wlrCookArrayFinal = [];
for(i=0;i= 4000) && ( document.cookie.split('; ').length < 19)){ //if current cookie's length is greater than or equal to 4000 (about 4K in size) & there are less than 19 cookies, create a new cookie
var x = document.cookie.charAt(document.cookie.lastIndexOf('wlrcookie')-1); //the last index of wlrcookie should be the most recent cookie
var xIncrement = x++;
document.cookie = xIncrement+'wlrcookie='+lrl+';expires=Fri, 17 Dec 2009 10:00:00 GMT';
}
else if(wlrCookArrayString.indexOf(threadNumberWc) < 0){ //if the thread number is not in any cookie,
if( document.cookie.split('; ').length < 18){
var arrSplit = wlrCookArrayString.split( "t%3D" );
arrSplit.shift();
arr = arrSplit.reverse(); //split it then reverse it so when allocate back to cookies, the first item(which will be the oldest anchor) will be allocated to the oldest cookie first - which will then be at the end of the cookie's value
putStringArrayBackToCookie(lrl, arr);
}
else{
var arrSplit = wlrCookArrayString.split( "t%3D" );
arrSplit.shift();
arr = arrSplit.reverse(); //split it then reverse it so when allocate back to cookies, the first item(which will be the oldest anchor) will be allocated to the oldest cookie first - which will then be at the end of the cookie's value
arr.pop();
putStringArrayBackToCookie(lrl, arr);
}
}
else if((wlrCookArrayString.indexOf(threadNumberWc) > -1) && (Number(regexCheat.slice(regexCheat.indexOf('%23r', regexCheat.indexOf(threadNumberWc))+4, regexCheat.indexOf('t%3D', regexCheat.indexOf(threadNumberWc)))) < Number(lrl.split('%23r')[1]))){ //if they move down an already tracked page - should save new anchor (if it's higher) and delete old one -
var toSearchFor = regexCheat.slice(regexCheat.indexOf(threadNumberWc)-4, regexCheat.indexOf('t%3D', regexCheat.indexOf(threadNumberWc))); //search & remove
if( document.cookie.split('; ').length < 18){
var repTosear = wlrCookArrayString.replace(""+toSearchFor+"", "");
if(repTosear.length === 0){
document.cookie = '0wlrcookie='+lrl+';expires=Fri, 17 Dec 2009 10:00:00 GMT';
}
else{
var arrSplit = repTosear.split( "t%3D" );
arrSplit.shift(); //remove first empty split on left
arr = arrSplit.reverse(); //split it then reverse it so when allocate back to cookies, the first item(which will be the oldest anchor) will be allocated to the oldest cookie first - which will then be at the end of the cookie's value
putStringArrayBackToCookie(lrl, arr);
}
}
else{
if(wlrCookArray[wlrCookArray.length-1].slice(wlrCookArray[wlrCookArray.length-1].lastIndexOf("t%3D")).indexOf(threadNumberWc) > -1){
var arrSplit = wlrCookArrayString.split("t%3D");
arrSplit.shift(); //remove first empty split on left
arr.pop(); //remove anchor from the end beacuse it contains the anchor we want to replace anyway
arr.pop(); //remove anchor from the end so enough room to put another one in cookie
arr = arrSplit.reverse(); //split it then reverse it so when allocate back to cookies, the first item(which will be the oldest anchor) will be allocated to the oldest cookie first - which will then be at the end of the cookie's value
putStringArrayBackToCookie(lrl, arr);
}
else{
wlrCookArrayString = wlrCookArrayString.replace(""+toSearchFor+"", "");
var arrSplit = wlrCookArrayString.split( "t%3D" );
arrSplit.shift(); //remove first empty split on left
arr.pop(); //remove anchor from the end so enough room to put another one in cookie
arr = arrSplit.reverse(); //split it then reverse it so when allocate back to cookies, the first item(which will be the oldest anchor) will be allocated to the oldest cookie first - which will then be at the end of the cookie's value
putStringArrayBackToCookie(lrl, arr);
}
}
}
}
function readFromCookieOnThread(){
if(document.cookie.indexOf('wlrcookie') > -1){
if(wlrCookArrayString.indexOf(threadNumberWc) > -1) {
var anchorfromCookie = regexCheat.slice(regexCheat.indexOf('%23r', regexCheat.indexOf(threadNumberWc))+4, regexCheat.indexOf('t%3D', regexCheat.indexOf(threadNumberWc)));
var getAnchorNumber;
for(h=0;h -1)){
alert("(document.URL.indexOf('#') < 0) && (anchorString.indexOf(anchorInPage) > -1)"+(document.URL.indexOf('#') < 0) && (anchorString.indexOf(anchorInPage) > -1));
window.location = anchorInPage;
} */
}
}
}
function findMin(numArrayLength, tempAnchorAray){
var tempHoldMeh;
for(j=0;j 0) && ((tempAnchorAray[j] < tempHoldMeh) || (tempHoldMeh === undefined))){
tempHoldMeh = tempAnchorAray[j];
lrl = encodeURIComponent(hrefArray[j].substr(hrefArray[j].indexOf('?')+1));
}
}
writeToCookie(lrl);
}
function saveTheCookieSaveTheWorld(){
if(document.URL.indexOf('bottom') > -1){
lrl = encodeURIComponent(hrefArray[hrefArray.length-1].substr(hrefArray[hrefArray.length-1].indexOf('?')+1));
writeToCookie(lrl);
}
else{
var numArrayLength = anchorAray.length;
var tempAnchorAray = [];
for(i=0;i -1){
$(this).children('img:last').after(' ');
}
else if(this.href.toLowerCase().lastIndexOf('.jpeg') > -1){
$(this).children('img:last').after(' ');
}
else if(this.href.toLowerCase().lastIndexOf('.bmp') > -1){
$(this).children('img:last').after(' ');
}
else if(this.href.toLowerCase().lastIndexOf('.png') > -1){
$(this).children('img:last').after(' ');
}
else if(this.href.toLowerCase().lastIndexOf('.gif') > -1){
$(this).children('img:last').after(' ');
}
});
}//end of run on forum-replies page
/***run on wiki pages****/
else if(document.URL.indexOf('wiki') > -1){
var theTextBox = $('#f_body')[0];
$('#f_body').after(wcButtons);
doStuffToTheText(theTextBox);
}
/***run on whim read****/
else if(document.URL.indexOf("whim-read")>-1){
for (key in smileys) {
var smilRep = $('#replies').html().replace(regex[key], smileys[key]);
$('#replies').html(smilRep);
}
}
/***run on whim send****/
else if(document.URL.indexOf("whim-send")>-1){
var theTextBox = $('#body')[0];
$('#body').css({width:'600px'}).before(wcButtons);
$('#buttonsDiv').css({fontSize: '80%', textAlign: 'center', marginTop: '5px', marginBottom: '5px', width:'600px'});
doStuffToTheText(theTextBox);
for (key in smileys) {
var smilRep = $('td[@bgcolor="#c3c9de"]').html().replace(regex[key], smileys[key]);
$('td[@bgcolor="#c3c9de"]').html(smilRep);
}
}
/***run on preview page****/
else if(document.URL.indexOf("reply")>-1){
var theTextBox = $('#body')[0];
$('#body').css({width:'600px',marginTop: '10px'}).before(wcButtons).parent().css('width','600px');
doStuffToTheText(theTextBox);
for (key in smileys) {
var smilRep = $('.bodytext:last').html().replace(regex[key], smileys[key]);
$('.bodytext:last').html(smilRep);
}
}
/***run on user page****/
else if(document.URL.indexOf("forum-user.cfm")>-1){
var theTextBox = $('#body')[0];
$('#body').before(wcButtons);
$('#buttonsDiv').css({fontSize: '80%', textAlign: 'center', marginTop: '5px', marginBottom: '5px'}).parent().css("width","410px").parent().parent().css("width","410px");
doStuffToTheText(theTextBox);
document.forms[ 1 ].elements.namedItem( 'body' ).style.width = "400px";
document.forms[ 1 ].elements.namedItem( 'body' ).setAttribute( "rows", "10");
document.forms[ 1 ].elements.namedItem( 'subject' ).style.width = "400px";
document.forms[ 1 ].elements.namedItem( 'subject' ).style.marginBottom = "20px";
if(document.URL.indexOf($(".nav_item_name > a > span").text().split('user ')[1]) > -1){
var aboutTr = $('tr[@valign=bottom]:first');
aboutTr.css({cursor:'pointer'}).children('td').css("opacity","0.5").end().next().attr('id','hider');
aboutTr.hover(function(){
$(this).children('td').css("opacity","1");
},function(){
if(trHide.css('display') == 'none'){
$(this).children('td').css("opacity","0.5");
}
else{
$(this).children('td').css("opacity","0.9");
}
});
var trHide = $('#hider');
trHide.hide();
aboutTr.toggle(function(){
trHide.css('display','block');
$(this).children('td').css('opacity','0.9');
},function(){
trHide.css('display','none');
$(this).children('td').css('opacity','0.5');
});
}
}
/***run on thread search page***/
else if((document.URL.indexOf("search")>-1) && (document.URL.indexOf("head") < 0)){
function mywrite(s) {
$("form[@action*=forum-search]").next().after('