andyed (owner)

Revisions

gist: 67454 Download_button fork
public
Public Clone URL: git://gist.github.com/67454.git
Embed All Files: show embed
Lizard Feeder GreaseMonkey Tag Cloud #
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// ==UserScript==
// @name Lizard Feeder: Focus/Context + Word Cloud
// @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.4 Feb 20, 2009
 * Initial version by Andy Edmonds
 * This script is licensed under the MPL.
 * Excluding ReplaceAll prototype (license unstated)
 */
 
 
String.prototype.replaceAll = function(pcFrom, pcTo){
var i = this.indexOf(pcFrom);
var c = this;
while (i > -1){
c = c.replace(pcFrom, pcTo);
i = c.indexOf(pcFrom);
}
return c;
}
 
var feedHack = {
refresh: 300,
timeout: false,
counts: {},
words: {},
ignore: { 'the': true, 'a':true, 'of':true, 'bug': true, '1': true, '2':true, 'mozilla': true, 'rt': true, 'its':true, 'doesnt': true,
'it':true, 'is':true, 'in': true, 'at': true, 'and':true, 'com':true, 'it':true, 'from':true, 'when':true, 'for':true,
'tinyurl':true, 'to': true, '0':true, 'and':true, 'bit':true, 'ly':true, 'https':true, 'on':true, 'no':true, 'do':true,'you':true,'all':true,
'with':true, 'how':true, 'be':true, 'like':true, 'will':true, 'me':true, 'my':true, 'but':true, 'can': true, 'as':true, 'or':true, 'not':true,
'are':true, 'does':true, 'if':true, 'that':true, 'has':true, 'an':true, 'also':true, 'www':true
}
};
 
 
 
feedHack.init = function init() {
$ = unsafeWindow.jQuery;
$("li.filter").css("opacity", .5);
$("li.filter").css("font-size", this.inactiveEm + 'em');
$("#intro").css("z-index", 20);
$("#content").append("<div style='position:absolute;top:180px;left:630px;z-index:10;opacity:.5;background-color:;width:400px;height:2000px;overflow:hidden;' id='wordpalette'>&nbsp;</div>");
window.setInterval(this.feedHack, this.refresh);
}
 
// 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 () {
$ = unsafeWindow.jQuery;
var text;
for(var type in feedHack.counts) {
feedHack.counts[type]=0;
$("li.filter.group-" + type).css("opacity", 1);
}
$("li.entry:visible").each(
function( offset ){
//console.log(this);
if($(this).css("maxWidth") != '360px') {
node = this.getElementsByTagName("A")[0].innerHTML;
node = node.replaceAll("http://","");
node = node.replaceAll("/"," ");
node = node.replaceAll("\\"," ");
node = node.replaceAll("."," ");
node = node.replaceAll("."," ");
node = node.replaceAll("."," ");
node = node.replaceAll(","," ");
node = node.replaceAll("- "," ");
node = node.replaceAll(" -"," ");
node = node.replaceAll("_"," ");
node = node.replaceAll(":"," ");
node = node.replaceAll("'"," ");
node = node.replaceAll('"',' ');
node = node.replaceAll('"',' ');
node = node.replaceAll(')','');
node = node.replaceAll('(','');
node = node.replaceAll('!','');
node = node.replaceAll('?','');
node = node.replaceAll('>','');
node = node.replaceAll('<','');
node = node.replaceAll('[','');
node = node.replaceAll(']','');
node = node.replaceAll(';','');
node = node.replaceAll('@','');
var nodes = node.split(" ");
for(var i =0;i<nodes.length;i++) {
text = nodes[i];
 
if(text.length > 1 && typeof(feedHack.ignore[text.toLowerCase()]) == 'undefined') {
if(typeof(feedHack.words[text.toLowerCase()]) == 'undefined') {
feedHack.words[text.toLowerCase()] = new Object;
feedHack.words[text.toLowerCase()].count=0;
feedHack.words[text.toLowerCase()].pretty=nodes[i];
//console.log("adding " + nodes[i]);
}
feedHack.words[text.toLowerCase()].count++
}
}
}
this.style.maxWidth = '360px';
 
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") ;
}
//console.log(feedHack.words);
 
for(j in feedHack.words) {
var id = "s" + encodeURIComponent(j);
var ele = $("#" + id);
var count =feedHack.words[j].count;
if(count > 2) {
if($("#" + id).length ) {
if( ele.attr("count") != count) {
var temp = $("#" + id).remove();
temp.prependTo("#wordpalette");
$("#" + id).css("fontSize", .5 + Math.log(count) + "em");
$("#" + id).attr("count", count);
}
} else {
$("#wordpalette").append('<span count="' + count + '" style="font-size:' + (.5 + Math.log(count)) + 'em;" id="' + id + '">' + feedHack.words[j].pretty + ' </span>');
 
}
}
}
}
 
 
feedHack.init();