-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchrome-dom-destroyer.js
112 lines (98 loc) · 3.73 KB
/
chrome-dom-destroyer.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
/**********************************
* Fast's DOM Destroyer Script *
* Chrome Console Edition *
**********************************/
// This is basically chrome-corrupter but less dangerous
// You SHOULD be able to run this safely
let DESTROYER = { PROPERTIES_CACHE: {}, STYLES_CACHE: {}, COUNT: 0, STYLECOUNT: 0 };
DESTROYER.PROPERTIES_TO_CORRUPT = ["className","style","src","href","text","innerText"] //,"fontFamily","innerText","name","color","background","backgroundImage","backgroundColor"];
DESTROYER.PROPERTY_CORRUPT_CHANCE = 0.8
DESTROYER.STYLES_TO_CORRUPT = ["fontFamily","color","background","backgroundImage","backgroundColor","width","height","textTransform"]
DESTROYER.STYLE_CORRUPT_CHANCE = 0.9
// prep cache tables
for( property of DESTROYER.PROPERTIES_TO_CORRUPT ){
DESTROYER.PROPERTIES_CACHE[property] = [];
}
for( property of DESTROYER.STYLES_TO_CORRUPT ){
DESTROYER.STYLES_CACHE[property] = [];
}
DESTROYER.removeInactive = function(list,cache){
for (let i = list.length-1; i >= 0; i--) {
let property = list[i]
if( cache[property].length == 0 ){
list.splice(i, 1)
}
}
}
DESTROYER.pickRandom = function(array = []) {
return array[ Math.floor(Math.random()*array.length) ];
};
DESTROYER.readValues = function(node){
for( property of DESTROYER.PROPERTIES_TO_CORRUPT ){
let value = node[property]
DESTROYER.PROPERTIES_CACHE[property].push( value )
}
};
DESTROYER.writeValues = function(node){
if( Math.random() > DESTROYER.PROPERTY_CORRUPT_CHANCE ){ return; }
for( property of DESTROYER.PROPERTIES_TO_CORRUPT ){
try{
let value = DESTROYER.pickRandom(DESTROYER.PROPERTIES_CACHE[property])
if( value == undefined || value == "" ){ continue; }
node[property] = value;
DESTROYER.COUNT++;
}
catch(e){}
}
};
DESTROYER.writeStyles = function(node){
let style = node.style
if( style == undefined ){
node.style = new CSSStyleDeclaration()
style = node.style
}
for( property of DESTROYER.STYLES_TO_CORRUPT ){
if( Math.random() > DESTROYER.STYLE_CORRUPT_CHANCE ){ continue; }
try{
let value = DESTROYER.pickRandom(DESTROYER.STYLES_CACHE[property])
if( value == undefined || value == "" ){ continue; }
style[property] = value
DESTROYER.STYLECOUNT++;
}
catch(e){}
}
};
DESTROYER.readStyles = function(node){
let style = node.style
if( style ){
for( property of DESTROYER.STYLES_TO_CORRUPT ){
let value = style[property]
if( value == undefined || value == "" ){ continue; }
DESTROYER.STYLES_CACHE[property].push( value )
}
}
};
DESTROYER.explore = function(node, action){
let shouldRun = true
for( node of node.children ){
shouldRun = false
DESTROYER.explore(node,action)
}
if( shouldRun ){
action(node);
}
};
// now ruin everything
(new Audio("https://cdn.discordapp.com/attachments/842273685422604328/860762192173072424/flashbang_lol.mp3")).play(); // lol
if( DESTROYER.PROPERTY_CORRUPT_CHANCE > 0 ){
DESTROYER.explore(document, DESTROYER.readValues);
DESTROYER.removeInactive( DESTROYER.PROPERTIES_TO_CORRUPT, DESTROYER.PROPERTIES_CACHE )
DESTROYER.explore(document, DESTROYER.writeValues);
console.log("Corrupted " + DESTROYER.COUNT + " DOM properties...");
}
if( DESTROYER.STYLE_CORRUPT_CHANCE > 0 ){
DESTROYER.explore(document, DESTROYER.readStyles);
DESTROYER.removeInactive( DESTROYER.STYLES_TO_CORRUPT, DESTROYER.STYLES_CACHE )
DESTROYER.explore(document, DESTROYER.writeStyles);
console.log("Corrupted " + DESTROYER.STYLECOUNT + " style attributes...");
}