-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtampermonkey_script.js
171 lines (159 loc) · 6.7 KB
/
tampermonkey_script.js
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
160
161
162
163
164
165
166
167
168
169
170
171
// ==UserScript==
// @name Loom2
// @namespace http://tampermonkey.net/
// @version 0.1
// @run-at document-start
// @description Loomifier
// @author Mohammad Raji
// @match https://bost.ocks.org/mike/hive/
// @match http://www.findtheconversation.com/concept-map/
// @match http://bl.ocks.org/NPashaP/raw/cd80ab54c52f80c4d84cad0ba9da72c2/eff5889494453282de12f55c47e5c11a4ca768b0/
// @match http://www.brightpointinc.com/labs/nfl_predictions/
// @match https://www.nytimes.com/interactive/2014/06/20/sports/worldcup/how-world-cup-players-are-connected.html?mtrref=undefined
// @match https://seelab.eecs.utk.edu/ecamp/index.php?c=164&nf=6×pan=all&threshold=10
// @match https://seelab.eecs.utk.edu/ecamp/index.php?c=228&nf=6×pan=all&threshold=10
// @match https://seelab.eecs.utk.edu/ecamp/index.php?c=170&nf=6×pan=all&threshold=10
// @grant none
// ==/UserScript==
(function() {
Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(a,b,c) {
if(c==undefined)
c=false;
this._addEventListener(a,b,c);
if(!this.eventListenerList)
this.eventListenerList = {};
if(!this.eventListenerList[a])
this.eventListenerList[a] = [];
//this.removeEventListener(a,b,c); // TODO - handle duplicates..
this.eventListenerList[a].push({listener:b,useCapture:c});
};
Element.prototype.getEventListeners = function(a){
if(!this.eventListenerList)
this.eventListenerList = {};
if(a==undefined)
return this.eventListenerList;
return this.eventListenerList[a];
};
Element.prototype.clearEventListeners = function(a){
if(!this.eventListenerList)
this.eventListenerList = {};
if(a==undefined){
for(var x in (this.getEventListeners())) this.clearEventListeners(x);
return;
}
var el = this.getEventListeners(a);
if(el==undefined)
return;
for(var i = el.length - 1; i >= 0; --i) {
var ev = el[i];
this.removeEventListener(a, ev.listener, ev.useCapture);
}
};
Element.prototype._removeEventListener = Element.prototype.removeEventListener;
Element.prototype.removeEventListener = function(a,b,c) {
if(c==undefined)
c=false;
this._removeEventListener(a,b,c);
if(!this.eventListenerList)
this.eventListenerList = {};
if(!this.eventListenerList[a])
this.eventListenerList[a] = [];
// Find the event in the list
for(var i=0;i<this.eventListenerList[a].length;i++){
if(this.eventListenerList[a][i].listener==b, this.eventListenerList[a][i].useCapture==c){ // Hmm..
this.eventListenerList[a].splice(i, 1);
break;
}
}
if(this.eventListenerList[a].length==0)
delete this.eventListenerList[a];
};
window.addEventListener("load", function(){
all_events = [];
configs = {};
configs.name = "root";
configs.id = -1;
configs.children = [];
var top_bar_height = window.screen.height - window.innerHeight - 24;
configs.window = {x: window.screenX, y: window.screenY + top_bar_height, width: window.innerWidth, height: window.innerHeight};
canvas = document.createElement("canvas");
canvas.width = document.body.clientWidth;
canvas.height = document.body.clientHeight;
canvas.style.width = "100%";
canvas.style.height = "100%";
canvas.style.position = "absolute";
canvas.style.left = 0;
canvas.style.top = 0;
canvas.style.pointerEvents = "none";
document.body.appendChild(canvas);
ctx = canvas.getContext("2d");
counter = 0;
function traverse(element)
{
if (element && element.tagName != undefined)
{
//element.style.fill = "red";
//element.setAttribute("fill", "red");
//element.style.border = "1px solid red";
events = element.getEventListeners();
if (Object.keys(events).length !== 0)
{
if (element.tagName == "g" && element.classList.contains("node"))
{
//var circle = element.querySelector("circle");
var text = "Target" + counter.toString();//element.querySelector("text>tspan").innerHTML;
all_events.push({element: element, events: events});
var rect = element.getBoundingClientRect();
var target = {rect:
{x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height
}
};
target.type="linear";
target.actor = "hover";
target.name = text;
target.id = counter;
configs.children.push(target);
counter += 1;
}
}
for (var i = 0; i < element.childNodes.length; i++)
{
traverse(element.childNodes[i]);
}
}
}
setTimeout(function(){
traverse(document.querySelector("svg"));
var i = 0;
/*
var timer = setInterval(function(){
var index = parseInt(i);
var events = all_events[index].events;
var element = all_events[index].element;
var types = Object.keys(events);
for (var j = 0; j < types.length; j++)
{
var ev = document.createEvent("SVGEvents");
ev = document.createEvent("SVGEvents");
ev.initEvent("mouseenter", true, false);
//element.dispatchEvent(ev);
//var rect = element.getBoundingClientRect();
//var left = parseInt(rect.left) + 1;
//var top = parseInt(rect.top) + 1;
setTimeout(function(){
ev = document.createEvent("SVGEvents");
ev.initEvent("mouseout", true, false);
element.dispatchEvent(ev);
}, 1000);
}
i++;
if (i > all_events.length)
clearInterval(timer);
}, 2000);*/
}, 5000);
});
})();