-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-links-please.user.js
39 lines (35 loc) · 1.11 KB
/
no-links-please.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
// No Links Please!
// version 0.2
//
// ==UserScript==
// @name No Links Please!
// @namespace http://jamesclarke.info
// @description disable links from everywhere but google
// @include *
// @exclude http://www.google.tld/search*
// @exclude http://www.google.tld/ig*
// @exclude http://maps.google.tld/*
// @exclude http://*search.yahoo.com/*
// @exclude https://mail.google.com/*
// @exclude http://mail.google.com/*
// @exclude http://www.google.tld/calendar/*
// @exclude http://portal.acm.org/*
// @exclude http://citeseer.ist.psu.edu/*
// ==/UserScript==
var links, a, href, replacement;
links = document.evaluate(
"//a[@href]",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < links.snapshotLength; i++) {
a = links.snapshotItem(i);
replacement = document.createElement('span');
if (a.hasChildNodes()) {
for (var j = 0; j < a.childNodes.length; j++) {
replacement.appendChild(a.childNodes[j]);
}
}
a.parentNode.replaceChild(replacement, a);
}