andyed (owner)

Revisions

gist: 55413 Download_button fork
public
Description:
Multi-column hack for Lizard Feeder (greasemonkey)
Public Clone URL: git://gist.github.com/55413.git
Embed All Files: show embed
Multicolumn Lizard Feeder #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// ==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();