// ==UserScript== // @name WLR Basic // @namespace http://forums.whirlpool.net.au // @version 0.1 // @description WLR Basic // @include http://forums.whirlpool.net.au/* // @include http://whirlpool.net.au/* // @exclude http://forums.whirlpool.net.au/forum-replies.cfm?*p=-2* // @exclude http://forums.whirlpool.net.au/forum-replies-archive.cfm* // ==/UserScript== $ = unsafeWindow.jQuery; unsafeWindow.jQuery.fn.reverse = function() { this.pushStack(this.get().reverse()); return this; } function kookeh_getValue(cN){ var regcheat = document.cookie+';'; return regcheat.slice( regcheat.indexOf(cN)+cN.length, regcheat.indexOf( ';', regcheat.indexOf(cN) ) ); } function kookeh_setValue(cN, v){ document.cookie = cN+'='+v+';path=/;domain=whirlpool.net.au;expires=Fri, 17 Dec 2009 10:00:00 GMT'; } /*******run on forum-threads.cfm page********/ /**** Last Read Function on forum-threads.cfm page*****/ var dUrl = document.URL; if((dUrl.indexOf('threads') > -1) || (dUrl.indexOf('user') > -1)){ $('a.title').each(function(){ }); } /*******run on forum-replies page********/ if(dUrl.indexOf('replies') > -1) { var lastReadLink, threadNumber = dUrl.split('t=')[1].split('&')[0]; var anchorArrRev = $('a[@title$=specific post]').reverse(); function hazRead(t){ anchorArrRev.each(function(i){ var curtop = 0; curtop = this.offsetTop; for (obj = this; obj != null; obj = obj.offsetParent){ //http://www.quirksmode.org/blog/archives/2008/01/using_the_assig.html#c10703 curtop += obj.offsetTop; } if( window.pageYOffset > curtop){ if(t == 'unload' && !lastReadLink){ lastReadLink = this.href; } else if(t == 'load'){ this.parentNode.parentNode.setAttribute('style', 'background:#C2C2C2 !important'); } } else if(i == anchorArrRev.length-1){ if(t == 'unload' && !lastReadLink){ lastReadLink = this.href.split('t=')[1]; } } }); return lastReadLink; } hazRead('load'); window.onunload = kookeh_setValue("lastRead", hazRead('unload')+''); }