-
Notifications
You must be signed in to change notification settings - Fork 57
/
skewer-everything.user.js
54 lines (48 loc) · 1.52 KB
/
skewer-everything.user.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
// ==UserScript==
// @name Skewer Everything
// @description Add a toggle button to run Skewer on the current page
// @lastupdated 2015-09-14
// @version 1.3
// @license Public Domain
// @include /^https?:///
// @grant none
// @run-at document-start
// ==/UserScript==
window.skewerNativeXHR = XMLHttpRequest;
window.skewerInject = inject;
var host = 'http://localhost:8080';
var toggle = document.createElement('div');
toggle.onclick = inject;
toggle.style.width = '0px';
toggle.style.height = '0px';
toggle.style.borderStyle = 'solid';
toggle.style.borderWidth = '0 12px 12px 0';
toggle.style.borderColor = 'transparent #F00 transparent transparent';
toggle.style.position = 'fixed';
toggle.style.right = 0;
toggle.style.top = 0;
toggle.style.zIndex = 214748364;
var injected = false;
function inject() {
if (!injected) {
var script = document.createElement('script');
script.src = host + '/skewer';
document.body.appendChild(script);
toggle.style.borderRightColor = '#0F0';
} else {
/* break skewer to disable it */
skewer.fn = null;
toggle.style.borderRightColor = '#F00';
}
injected = !injected;
localStorage._autoskewered = JSON.stringify(injected);
}
document.addEventListener('DOMContentLoaded', function() {
/* Don't use on iframes. */
if (window.top === window.self) {
document.body.appendChild(toggle);
if (JSON.parse(localStorage._autoskewered || 'false')) {
inject();
}
}
});