- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
157 lines (136 loc) · 5.6 KB
/
Copy pathscript.js
File metadata and controls
157 lines (136 loc) · 5.6 KB
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
(function(){
const$=(s,p=document)=>p.querySelector(s);
const$$=(s,p=document)=>[...p.querySelectorAll(s)];
// --- SCANLINES ---
constov=document.createElement('div');
ov.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:999999;background:repeating-linear-gradient(0deg,rgba(0,0,0,0.05) 0px,rgba(0,0,0,0.05) 1px,transparent 1px,transparent 2px);';
document.body.appendChild(ov);
constglyphPool='!@#░▒▓█▄▀■◊●~^*?¿ñøæ∑∆πΩ';
constrc=()=>glyphPool[Math.floor(Math.random()*glyphPool.length)];
constrh=()=>`hsl(${Math.random()*360|0},100%,55%)`;
constrp=(n)=>(Math.random()-0.5)*2*n;
// Drift state per element
constdrifts=newMap();
functiongetDrift(el){
if(!drifts.has(el))drifts.set(el,{x: 0,y: 0,r: 0,ox: el.style.cssText});
returndrifts.get(el);
}
// --- EFFECT: drift elements physically ---
functiondriftEl(el,strength){
constd=getDrift(el);
d.x+=rp(strength*0.8);
d.y+=rp(strength*0.5);
d.r+=rp(strength*0.3);
// Clamp drift so it doesn't fly off screen
d.x=Math.max(-strength*6,Math.min(strength*6,d.x));
d.y=Math.max(-strength*4,Math.min(strength*4,d.y));
d.r=Math.max(-strength*1.5,Math.min(strength*1.5,d.r));
el.style.transform=`translate(${d.x.toFixed(1)}px, ${d.y.toFixed(1)}px) rotate(${d.r.toFixed(2)}deg)`;
el.style.position='relative';
}
// --- EFFECT: swap two text nodes ---
functionswapTexts(nodes){
if(nodes.length<2)return;
consta=nodes[Math.random()*nodes.length|0];
constb=nodes[Math.random()*nodes.length|0];
if(a!==b&&a.nodeValue&&b.nodeValue){
[a.nodeValue,b.nodeValue]=[b.nodeValue,a.nodeValue];
}
}
// --- EFFECT: corrupt a string ---
functioncorruptStr(str,rate){
returnstr.split('').map(c=>c.trim()&&Math.random()<rate ? rc() : c).join('');
}
// --- EFFECT: glitch input/textarea value ---
functionglitchInput(el,rate){
if(!el||!el.value)return;
constorig=el.value;
el.value=corruptStr(orig,rate);
setTimeout(()=>el.value=orig,120);
}
// --- EFFECT: shake the translated output box ---
functionshakeOutput(strength){
constout=$('.ryNqvb')||$('[jsname="W297wb"]')||$('.lRu31')||$('.HwtpBd');
if(!out)return;
driftEl(out,strength*1.5);
if(Math.random()<0.3)out.style.color=rh();
}
// --- EFFECT: spin the language selector buttons ---
functionspinLangButtons(strength){
$$('.VfPpkd-LgbsSe[jsname], [data-language-code], .ccvoYb').forEach(el=>{
if(Math.random()<0.4)driftEl(el,strength*0.8);
});
}
// --- EFFECT: warp the swap-language arrow button ---
functionwarpSwapBtn(strength){
constbtn=$('[jsname="Iqt6T"]')||$('.N37NMd button')||$('[aria-label*="wap"]');
if(!btn)return;
btn.style.transform=`rotate(${(Date.now()/(200/strength))%360}deg) scale(${1+Math.sin(Date.now()/200)*0.3*(strength/10)})`;
}
// --- EFFECT: move entire panels ---
functionjoltPanels(strength){
constpanels=$$('.aTGhEe, .rmcAZb, .j3mWee, .kn8PE, [data-location="source"], [data-location="target"]');
panels.forEach(p=>{
if(Math.random()<0.25)driftEl(p,strength);
});
}
// --- EFFECT: randomly reorder child elements of a container ---
functionshuffleChildren(strength){
if(Math.random()>strength/50)return;
constcontainers=$$('.aTGhEe, .rmcAZb, .lRu31');
if(!containers.length)return;
constc=containers[Math.random()*containers.length|0];
constkids=[...c.children];
if(kids.length<2)return;
consti=Math.random()*kids.length|0;
constj=Math.random()*kids.length|0;
if(i!==j){
constref=kids[j].nextSibling;
c.insertBefore(kids[j],kids[i]);
if(ref)c.insertBefore(kids[i],ref);
}
}
// --- EFFECT: RGB split on body ---
functionrgbSplit(strength){
consts=strength*0.6;
document.body.style.textShadow=`${rp(s)}px 0 rgba(255,0,0,0.5),${rp(s)}px 0 rgba(0,255,0,0.45),${rp(s)}px 0 rgba(0,0,255,0.5)`;
}
// --- EFFECT: flash translate button ---
functionflashBtn(strength){
constbtn=$('[jsname="vSSGHe"]')||$('[aria-label*="Translate"]');
if(!btn)return;
btn.style.background=rh();
btn.style.transform=`scale(${1+Math.random()*strength*0.05}) rotate(${rp(strength*0.5)}deg)`;
}
// strength: 1–10
constSTRENGTH=8;
lettick=0;
setInterval(()=>{
tick++;
consts=STRENGTH;
shakeOutput(s);
spinLangButtons(s);
warpSwapBtn(s);
joltPanels(s);
if(tick%3===0)shuffleChildren(s);
if(tick%2===0)rgbSplit(s);
if(tick%4===0)flashBtn(s);
// Glitch the source textarea
constta=$('textarea')||$('[contenteditable="true"]');
if(ta&&Math.random()<0.08*(s/5))glitchInput(ta,0.05*(s/5));
// Corrupt output text nodes
constoutEl=$('.ryNqvb')||$('[jsname="W297wb"]');
if(outEl){
constwalker=document.createTreeWalker(outEl,NodeFilter.SHOW_TEXT);
constnodes=[];
while(walker.nextNode())nodes.push(walker.currentNode);
nodes.forEach(n=>{
if(n.nodeValue.trim()&&Math.random()<0.12*(s/5)){
n.nodeValue=corruptStr(n.nodeValue,0.08*(s/5));
}
});
if(Math.random()<0.15)swapTexts(nodes);
}
},60);
console.log('%c🌐 TRANSLATE CORRUPTED','color:red;font-size:20px;font-weight:bold');
})();