This repository was archived by the owner on Nov 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathctrl-f-d.js
executable file
·133 lines (107 loc) · 5.26 KB
/
ctrl-f-d.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
/*
Ctrl+F'd
A bookmarklet script to censor text on a web page, in the Rush Limbaugh style.
by Greg Leuch <http://www.gleuch.com>
------------------------------------------------------------------------------------
Why Rush, you ask? Read this: http://www.gleuch.com/play/ctrl-f-d
*/
Array.prototype.in_array = function(p_val, sensitive) {for(var i = 0, l = this.length; i < l; i++) {if ((sensitive && this[i] == p_val) || (!sensitive && this[i].toLowerCase() == p_val.toLowerCase())) {return true;}} return false;};
function rgb2hex(rgb) {rgb = rgb.replace(/\s/g, "").replace(/^(rgb\()(\d+),(\d+),(\d+)(\))$/, "$2|$3|$4").split("|"); return "#" + hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);}
function hex(x) {var hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F"); return isNaN(x) ? "00" : hexDigits[(x-x%16)/16] + hexDigits[x%16];}
var $_ = false, $ctrl_f_d = document.createElement('script'), local = true;
$ctrl_f_d.src = 'http://assets.gleuch.com/jquery-latest.js';
$ctrl_f_d.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild($ctrl_f_d);
function ctrlfd_wait() {
if ((local && typeof(jQuery) == 'undefined') || (!local && typeof(unsafeWindow.jQuery) == 'undefined')) {
window.setTimeout(ctrlfd_wait,100);
} else {
ctrlfd_start(local ? jQuery : unsafeWindow.jQuery);
}
}
function ctrlfd_start($_) {
$_.fn.reverse = function(){return this.pushStack(this.get().reverse(), arguments);};
(function($_) {
$_.ctrlfd = function(data, c) {
if (!$_.ctrlfd.settings.finish) $_.ctrlfd.init();
$_(data).ctrlfd(c);
if (!$_.ctrlfd.settings.finish) $_.ctrlfd.finish();
};
$_.fn.ctrlfd = function(c) {
return this.filter(function() {return $_.ctrlfd.filter(this);}).each(function() {$_.ctrlfd.censor(this, c);});
};
$_.extend($_.ctrlfd, {
settings : {hide_bg : true, tag_start : '<span class="ctrlfd">', tag_end : '</span>', init : false, finish : false},
filter : function(self) {
if (self.nodeType == 1) {
var tag = self.tagName.toLowerCase();
return !(self.className.match('ctrlfd') || tag == 'head' || tag == 'img' || tag == 'script');
} else {
return true;
}
},
censor : function(self, c) {
$_(self).css({'text-shadow' : 'none'});
if (self.nodeType == 3) {
if (self.nodeValue.replace(/\s/ig, '') != '') {
if (!c) c = $_(self).parent() ? $_(self).parent().css('color') : '#000000';
var ntb = '<span class="ctrlfd" style="color: '+ c +'; background-color:'+c+';">';
$_(self).after(ntb+ self.nodeValue.replace(/\s\s/ig, ' ').replace(/\n/ig, '').split(' ').join($_.ctrlfd.settings.tag_end +' '+ ntb) + $_.ctrlfd.settings.tag_end);
self.nodeValue = '';
}
} else if (self.nodeType == 1) {
c = rgb2hex($_(self).css('color'));
if ($_(self).children().length > 0) {
$_.ctrlfd($_(self).contents(), c);
} else if ($_(self).children().length == 0) {
$_(self).html($_.ctrlfd.settings.tag_start + $_(self).text() + $_.ctrlfd.settings.tag_end).addClass('ctrlfd').css({'background-color': c});
} else {
$_(self).addClass('ctrlfd');
}
}
},
init : function() {
$_.ctrlfd.settings.init = true;
},
finish : function() {
$_(document).each(function() {
var r = this.title.split(" ");
for (var i=0; i<r.length; i++) if (!(/(\||\-)/ig).test(r[i])) r[i] = r[i].replace(/\S/ig, '-');
this.title = r.join(' ');
});
setTimeout(function() {
$_('object,embed,iframe').each(function() {
var r = $_(this);
r.wrap(document.createElement('div'));
var s = $_(this).parent();
s.css({width: r.width(), height: r.height()}).addClass('ctrlfd');
r.remove();
});
}, 1000);
$_('img, input[type=image]').each(function() {
var r = $_(this), w = r.width(), h = r.height();
r.css({width: r.width(), height: r.height()}).attr('src', 'http://assets.gleuch.com/blank.png').width(w).height(h);
});
var s = document.createElement("style");
s.innerHTML = ".ctrlfd {font-size: inherit !important; "+ ($_.ctrlfd.settings.hide_bg ? "background-image: none !important;" : "") +"} .bg_ctrlfd {"+ ($_.ctrlfd.settings.hide_bg ? "background-image: none !important;" : "") +"} select, input, textarea, object, embed, img, button, hr {background: #000 !important; color: #000 !important; border-color: #000 !important;}";
$_('head').append(s);
/*if ($_.ctrlfd.settings.hide_bg) $_('body *, body, html').each(function() {$_(this).addClass('bg_ctrlfd');});*/
$_.ctrlfd.settings.finish = true;
}
});
})($_);
/* $(window).ready(function() { */
/* Remove some shitty ads */
$('iframe, a[href~=atdmt], script[src~=doubleclick]').remove();
/* }); */
/* $_(document).ready(function() { */
$_.ctrlfd('html', '#000000');
/* setTimeout(function() {
if ($_.ctrlfd.settings.md5 != $('*').size()) {
$_.ctrlfd('html', '#000000');
$_.ctrlfd.settings.md5 = $('*').size();
}
}, 2000); */
/* }); */
}
ctrlfd_wait();