Boa tarde pessoal,
Hoje por ser um dia mais tranquilo no trabalho, resolvi brincar um pouco com jQuery e javascript.
Como resultado, acabei criando uma espécie de plugin cliente para ordenar os tópicos de uma página do GUJ.
Basicamente ele injeta um plugin de ordenação do jquery e aplica na tabela de tópicos.
Para usar basta criar um Bookmarklet com o código abaixo, e clicar quando estiver na página de tópicos.
Ao clicar no título da coluna, ele fará a ordenação.
javascript:(function(){function c(a,b){var c=document.createElement("link");c.href=a;var d=document.getElementsByTagName("head")[0],e=false;c.onload=c.onreadystatechange=function(){if(!e&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){e=true;b();c.onload=c.onreadystatechange=null;d.removeChild(c)}};d.appendChild(c)}function d(a,b){var c=document.createElement("script");c.src=a;var d=document.getElementsByTagName("head")[0],e=false;c.onload=c.onreadystatechange=function(){if(!e&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){e=true;b();c.onload=c.onreadystatechange=null;d.removeChild(c)}};d.appendChild(c)}function e(){a.innerHTML=msg;b.appendChild(a);window.setTimeout(function(){if(typeof jQuery=="undefined"){b.removeChild(a)}else{jQuery(a).fadeOut("slow",function(){jQuery(this).remove()});if(otherlib){$jq=jQuery.noConflict()}}},2500)}var a=document.createElement("div"),b=document.getElementsByTagName("body")[0];otherlib=false,msg="";a.style.position="fixed";a.style.height="32px";a.style.width="220px";a.style.marginLeft="-110px";a.style.top="0";a.style.left="50%";a.style.padding="5px 10px";a.style.zIndex=1001;a.style.fontSize="12px";a.style.color="#222";a.style.backgroundColor="#f99";if(typeof jQuery!="undefined"){msg="This page already using jQuery v"+jQuery.fn.jquery}else if(typeof $=="function"){otherlib=true;return e()}d("http://code.jquery.com/jquery-latest.min.js",function(){if(typeof jQuery=="undefined"){msg="Sorry, but jQuery wasn't able to load"}else{msg="This page is now jQuerified with v"+jQuery.fn.jquery;if(otherlib){msg+=" and noConflict(). Use $jq(), not $()."}}return e()});c("http://cdn.ucb.org.br/Scripts/tablesorter/blue/style.css",function(){});d("http://cdn.ucb.org.br/Scripts/tablesorter/jquery.tablesorter.min.js",function(){var a=$(".forumline");var b=$("th",a);a.prepend("<thead><tr></tr></thead>");var c=$("thead tr",a);c.append(b.clone());b.parent().remove();a.tablesorter()})})()
Observações:
- Funciona no Chrome e no IE. No Firefox, parece rolar um conflito com o plugin de bordas.