// ==UserScript== // @name Lizard Feeder: Multicolumn + Focus Context // @namespace feeds.mozilla.com // @include http://feeds.mozilla.com/ // ==/UserScript== /* * Multi-column (just add float left, line 29) * unsuccesful port to DOM mutation * Version 0.0.1 Jan 26, 2009 * Initial version by Andy Edmonds * This script is licensed under the MPL. */ var feedHack = { refresh: 800, timeout: false, counts: {}, ems: .8, baseEm: .9, inactiveEm: .8, }; feedHack.init = function init() { //unsafeWindow.addEventListener("DOMNodeInserted", this.mutated, false); this.addGlobalStyle('.entry { float:left ! important; max-width: 380px; min-height:140px; min-width:380px; }'); $ = unsafeWindow.jQuery; $("li.filter").css("opacity", .5); $("li.filter").css("font-size", this.inactiveEm + 'em'); window.setInterval(this.feedHack, 300); } // From http://diveintogreasemonkey.org/patterns/add-css.html feedHack.addGlobalStyle = function (css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } feedHack.feedHack = function () { for(var type in feedHack.counts) { feedHack.counts[type]=0; $("li.filter.group-" + type).css("opacity", 1); } $ = unsafeWindow.jQuery; $("li.entry:visible").each( function( offset ){ this.style.maxWidth = '360px'; this.style.minHeight = '160px;' if(offset % 2) { this.style.cssFloat == 'left'; } else { this.style.cssFloat = 'left'; //this.parentNode.style.float= 'right'; } var arClass = this.className.split(" "); for(var classOffset = 0; classOffset < arClass.length; classOffset++) { if(arClass[classOffset].indexOf("group-") > -1) { var type = arClass[classOffset].split("-")[1]; if(!feedHack.counts[type]) feedHack.counts[type]=0; feedHack.counts[type]++; } } }); var sum = 0; for(var type in feedHack.counts) { sum += feedHack.counts[type]; } for(var type in feedHack.counts) { //console.log("Bouns ems " + (feedHack.counts[type]/sum)+ " " + ((1.0 * feedHack.baseEm + ((feedHack.counts[type]/sum)*feedHack.ems)) + "em") ); $("li.group-"+ type + ".filter" ).css("font-size", (1.0 * feedHack.baseEm + ((feedHack.counts[type]/sum)*feedHack.ems)) + "em") ; } } feedHack.mutated = function (evt) { //$("#intro-about").html("mt " + Math.random(1) + evt.target.nodeName + " " + evt.target + " " + evt.target.parentNode.nodeName ); //var node = $(evt.target.parentNode); evt.target.parentNode.style.border = '1px solid #fc0'; evt.target.parentNode.innerHTML += evt.target.parentNode.nodeName; } feedHack.init();