User:Pcj/global.js

ajaxPages = ["Special:RecentChanges","Special:Watchlist","Special:Log","Special:Contributions"]; importScriptPage('AjaxRC/code.js', 'dev');

function fixBlogLinks { rclist = ($("#mw-rc-subentries-0").length)?$("#WikiaMainContent > div > table:contains('Blog comment')"):$("#WikiaMainContent ul.special li:contains('Blog comment')"); rclist.each(function (i) { lnk = $(this).find("a:contains('hist')").attr("href"); if (typeof(lnk) != "undefined") { rawID = lnk.replace(/.*curid=(.*?)&.*/,"$1"); $(this).find("a:contains('User blog:')").attr("href","/wiki/User_blog:" + lnk.replace(/.*User_blog_comment:(.*?\/.*?)\/.*/,"$1") + "#comm-" + rawID); } }); }

function goToBlogPageWithComment { hash = document.location.hash; if (hash.indexOf("#comm-") != -1 && !$(hash).length) { for (x=2;x<=$(".upper-pagination > div > a:last-child").prev.text;x++) { $("#article-comments").load("/wiki/"+wgPageName+"?page="+x+" #article-comments",function (data) { if ($(hash).length) document.location.href = "/wiki/"+wgPageName+"?page=" + $(".article-comments-pagination-link-active").eq(0).text + hash; }); } } }

function fbl { if (wgCanonicalNamespace == "User_blog") goToBlogPageWithComment; if (wgPageName == "Special:RecentChanges") { fixBlogLinks; $("#WikiaMainContent").bind("ajaxPageLoad",fixBlogLinks); } } addOnloadHook(fbl);