-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserscript.js
More file actions
476 lines (422 loc) · 19.8 KB
/
Userscript.js
File metadata and controls
476 lines (422 loc) · 19.8 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// ==UserScript==
// @name websniper-custom-keywords-upd
// @namespace http://tampermonkey.net/
// @version 1.3 - custom keywords!
// @description hi, thanks for using my sniper <3, if you have issues dm me or join this server for updates: discord.gg/7zuFCT8kYJ
// @author .lunary. on dc (dms open)
// @match https://discord.com/*
// @grant GM_xmlhttpRequest
// @connect raw.githubusercontent.com
// @run-at document-end
// ==/UserScript==
// CUSTOM KEYWORDS HERE!!
const custom_keywords = [
"aidioauzdabiuda",
"wegrdgfhngfnf",
"wagsgsgegag"
];
(async function() {
'use strict';
let dreamspaceenabled = true
let cyberspaceenabled = true
let glitchenabled = true
let customenabled = false
let formattedRequiredG = [], formattedRequiredD = [], formattedRequiredC = [], formattedRequiredCustom = [], formattedIgnoreKeywords = [], ignoreKeywords = [], requiredG = [], requiredD = [], requiredC = [], requiredCustom = [];
const audio = new Audio("put a .mp3 or any other form of audio link here (might have issues playing due to reaching to another site)"); // this is the sound that plays when a link is sniped
// --- outer box (keep yours or replace with this) ---
const box = document.createElement('div');
box.id = 'logBox';
Object.assign(box.style, {
position: 'fixed',
top: '10px',
right: '10px',
width: '800px',
height: '300px',
background: 'rgba(100, 100, 100, 0.5)',
backdropFilter: 'blur(8px)',
WebkitBackdropFilter: 'blur(8px)',
color: '#FFF',
fontFamily: 'monospace',
fontSize: '12px',
padding: '10px',
border: '1px solid #FFF',
borderRadius: '8px',
zIndex: '9999999999999999999999999999999999999999999999',
cursor: 'move',
display: 'flex',
flexDirection: 'column',
boxSizing: 'border-box' // make padding count toward width/height
});
// --- top header row (title + buttons on one line) ---
const headerRow = document.createElement('div');
Object.assign(headerRow.style, {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
gap: '8px',
boxSizing: 'border-box'
});
// title (left side)
const title = document.createElement('div');
title.textContent = 'Debug Box';
Object.assign(title.style, {
padding: '5px 10px',
cursor: 'default',
userSelect: 'none',
display: 'inline-block'
});
// buttons container (right side of header)
const headerButtons = document.createElement('div');
Object.assign(headerButtons.style, {
display: 'flex',
gap: '8px',
alignItems: 'center'
});
// create your toggle buttons (Gbutton, Dbutton, Cbutton) and clear
const Gbutton = document.createElement('button');
Gbutton.textContent = `glitch: ${glitchenabled}`;
const Dbutton = document.createElement('button');
Dbutton.textContent = `dreamspace: ${dreamspaceenabled}`;
const Cbutton = document.createElement('button');
Cbutton.textContent = `cyberspace: ${cyberspaceenabled}`;
const Custombutton = document.createElement('button');
Custombutton.textContent = `custom keywords: ${customenabled}`;
const clearbtn = document.createElement('button');
clearbtn.textContent = 'clear logs';
// uniform button styling
const buttonStyle = {
background: 'rgba(80, 80, 80, 0.80)',
color: '#FFF',
fontFamily: 'monospace',
fontSize: '12px',
border: '1px solid #FFF',
borderRadius: '8px',
padding: '5px 10px',
userSelect: 'none',
};
Object.assign(Gbutton.style, buttonStyle);
Object.assign(Dbutton.style, buttonStyle);
Object.assign(Cbutton.style, buttonStyle);
Object.assign(Custombutton.style, buttonStyle);
Object.assign(clearbtn.style, buttonStyle);
Object.assign(title.style, buttonStyle);
// append header stuff
headerButtons.appendChild(Gbutton);
headerButtons.appendChild(Dbutton);
headerButtons.appendChild(Cbutton);
headerButtons.appendChild(Custombutton);
headerButtons.appendChild(clearbtn);
headerRow.appendChild(title);
headerRow.appendChild(headerButtons);
box.appendChild(headerRow);
// small spacer if needed
const spacer = document.createElement('div');
spacer.style.height = '8px';
box.appendChild(spacer);
// --- log content area (flow child, not absolute) ---
const logContent = document.createElement('div');
Object.assign(logContent.style, {
width: '100%',
height: 'calc(100% - 40px)',
padding: '6px 8px',
boxSizing: 'border-box',
overflowY: 'auto',
color: '#FFF',
fontFamily: 'monospace',
fontSize: '12px',
lineHeight: '1.2em',
display: 'flex',
flexDirection: 'column',
gap: '4px'
});
box.appendChild(logContent);
// optional: small footer row or status line
const footer = document.createElement('div');
Object.assign(footer.style, {
marginTop: '6px',
fontSize: '11px',
opacity: '0.9',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
});
// add to document
document.body.appendChild(box);
Gbutton.addEventListener('mouseenter', () => {
Gbutton.style.background = 'rgba(100, 100, 100, 0.85)';
});
Gbutton.addEventListener('mouseleave', () => {
Gbutton.style.background = 'rgba(80, 80, 80, 0.80)';
});
Dbutton.addEventListener('mouseenter', () => {
Dbutton.style.background = 'rgba(100, 100, 100, 0.85)';
});
Dbutton.addEventListener('mouseleave', () => {
Dbutton.style.background = 'rgba(80, 80, 80, 0.80)';
});
Cbutton.addEventListener('mouseenter', () => {
Cbutton.style.background = 'rgba(100, 100, 100, 0.85)';
});
Cbutton.addEventListener('mouseleave', () => {
Cbutton.style.background = 'rgba(80, 80, 80, 0.80)';
});
Custombutton.addEventListener('mouseenter', () => {
Custombutton.style.background = 'rgba(100, 100, 100, 0.85)';
});
Custombutton.addEventListener('mouseleave', () => {
Custombutton.style.background = 'rgba(80, 80, 80, 0.80)';
});
clearbtn.addEventListener('mouseenter', () => {
clearbtn.style.background = 'rgba(100, 100, 100, 0.85)';
});
clearbtn.addEventListener('mouseleave', () => {
clearbtn.style.background = 'rgba(80, 80, 80, 0.80)';
});
// Make it draggable
let dragging = false, offsetX = 0, offsetY = 0;
box.addEventListener('mousedown', (e) => {
dragging = true;
offsetX = e.clientX - box.getBoundingClientRect().left;
offsetY = e.clientY - box.getBoundingClientRect().top;
e.preventDefault();
});
document.addEventListener('mousemove', (e) => {
if (dragging) {
box.style.left = (e.clientX - offsetX) + 'px';
box.style.top = (e.clientY - offsetY) + 'px';
box.style.right = 'auto';
}
});
document.addEventListener('mouseup', () => {
dragging = false;
});
function logBox(message) {
const now = new Date();
const time = now.toLocaleTimeString('en-GB', { hour12: false });
const milliseconds = now.getMilliseconds().toString().padStart(3, '0');
const timestamp = `${time}.${milliseconds}`;
const entry = document.createElement('div');
entry.textContent = `[${timestamp}] ${message}`;
logContent.appendChild(entry);
logContent.scrollTop = logContent.scrollHeight;
};
Gbutton.addEventListener('click', () => {
if (glitchenabled) {glitchenabled = false; logBox("No longer sniping glitch")} else {glitchenabled = true; logBox("Sniping glitch");}
Gbutton.textContent = `glitch: ${glitchenabled}`;
});
Dbutton.addEventListener('click', () => {
if (dreamspaceenabled) {dreamspaceenabled = false; logBox("No longer sniping dreamspace");} else {dreamspaceenabled = true; logBox("Sniping dreamspace");}
Dbutton.textContent = `dreamspace: ${dreamspaceenabled}`;
});
Cbutton.addEventListener('click', () => {
if (cyberspaceenabled) {cyberspaceenabled = false; logBox("No longer sniping cyberspace");} else {cyberspaceenabled = true; logBox("Sniping cyberspace");}
Cbutton.textContent = `cyberspace: ${cyberspaceenabled}`;
});
Custombutton.addEventListener('click', () => {
if (customenabled) {customenabled = false; logBox("No longer using custom keywords");} else {customenabled = true; logBox("Using custom keywords");}
Custombutton.textContent = `custom keywords: ${customenabled}`;
});
clearbtn.addEventListener('click', () => {
logContent.innerHTML = '';
});
function fetchJSON(url) {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: url,
headers: {
"Accept": "application/json"
},
onload: function(response) {
if (response.status >= 200 && response.status < 300) {
try {
const data = JSON.parse(response.responseText);
resolve(data);
} catch (e) {
reject(new Error("Failed to parse JSON"));
}
} else {
reject(new Error(`HTTP error! status: ${response.status}`));
}
},
onerror: function(err) {
reject(new Error("Network error"));
}
});
});
}
logBox('by .lunary.');
if (!glitchenabled) logBox("Glitch will not be sniped");
else logBox("Glitch will be sniped");
if (!dreamspaceenabled) logBox("Dreamspace will not be sniped");
else logBox("Dreamspace will be sniped");
if (!cyberspaceenabled) logBox("Cyberspace will not be sniped");
else logBox("Cyberspace will be sniped");
if (!customenabled) logBox("Not using custom keywords");
else logBox("Using custom keywords");
// get keyword list (took so long bro i suck at this)
let processedMessageIds = new Set();
let deeelay = 25
let pleasewait = true
const formatKeywords = (keywords) =>
Array.isArray(keywords)
? keywords.map(keyword => keyword.replace(/<space>/g, ' '))
: [];
async function init() {
try {
const json = await fetchJSON('https://raw.githubusercontent.com/Lunatic-T/Websniper/main/Keywords.json');
logBox('fetched keyword data');
requiredD = json.requiredD
requiredG = json.requiredG
requiredC = json.requiredC
requiredCustom = custom_keywords
ignoreKeywords = json.ignoreKeywords
formattedRequiredG = formatKeywords(requiredG);
formattedRequiredD = formatKeywords(requiredD);
formattedRequiredC = formatKeywords(requiredC);
formattedRequiredCustom = formatKeywords(requiredCustom);
formattedIgnoreKeywords = formatKeywords(ignoreKeywords);
setInterval(processLatestMessage, deeelay);
} catch(e) {
console.error("Failed to fetch JSON:", e);
logBox("Error fetching keywords, aborting.");
}
}
let __checkpass__ = false
// Function to process and click only the latest message
function processLatestMessage() {
const messageContainer = document.querySelector('ol[role="list"]');
if (!messageContainer) return;
const messages = messageContainer.querySelectorAll('li[class*="messageListItem"]');
if (!messages || messages.length === 0) return;
const latestMessage = messages[messages.length - 1];
if (!latestMessage) return;
let messageReal = latestMessage.querySelector('[id^="message-content-"]');
if (!messageReal) {
// fallback: find any div that contains a roblox link text
const allDivs = latestMessage.querySelectorAll('div');
for (const div of allDivs) {
if (div.textContent && div.textContent.toLowerCase().includes('roblox.com')) {
messageReal = div;
break;
}
}
}
if (!messageReal) {
console.error('Message content not found for latest message');
return;
}
// Use a stable identifier for the message. If data-list-item-id missing, use element reference
let messageId = latestMessage.querySelector('[data-list-item-id]')?.getAttribute('data-list-item-id');
let useElementKey = false;
if (!messageId) {
// fallback key — this will be unique per DOM node instance
messageId = 'el-' + (latestMessage.__snId || (latestMessage.__snId = Math.random().toString(36).slice(2)));
useElementKey = true;
}
// If we've already fully processed this message, skip
if (processedMessageIds.has(messageId)) {
//console.debug('Already processed messageId', messageId);
return;
}
const textContent = messageReal.textContent.toLowerCase();
// keyword checks
let hasRequiredD = formattedRequiredD.some(keyword => keyword && textContent.includes(keyword));
let hasRequiredG = formattedRequiredG.some(keyword => keyword && textContent.includes(keyword));
let hasRequiredC = formattedRequiredC.some(keyword => keyword && textContent.includes(keyword));
let hasRequiredCustom = formattedRequiredCustom.some(keyword => keyword && textContent.includes(keyword));
let hasIgnoreKeyword = formattedIgnoreKeywords.some(keyword => keyword && textContent.includes(keyword));
const matchedRequiredD = formattedRequiredD.filter(k => k && textContent.includes(k.toLowerCase()));
const matchedRequiredG = formattedRequiredG.filter(k => k && textContent.includes(k.toLowerCase()));
const matchedRequiredC = formattedRequiredC.filter(k => k && textContent.includes(k.toLowerCase()));
const matchedRequiredCustom = formattedRequiredCustom.filter(k => k && textContent.includes(k.toLowerCase()));
const matchedIgnored = formattedIgnoreKeywords.filter(k => k && textContent.includes(k.toLowerCase()));
if (matchedIgnored.length > 0) {
console.warn('Message skipped: contains ignored keywords.', { matchedIgnored });
}
// Debug warnings (remove the // at the start of each line below this to toggle it on)
// if (matchedRequiredG.length === 0) console.warn('No requiredG found in message', { matchedRequiredG });
// if (matchedRequiredD.length === 0) console.warn('No requiredD found in message', { matchedRequiredD });
// if (matchedRequiredC.length === 0) console.warn('No requiredC found in message', { matchedRequiredC });
// if (matchedRequiredCustom.length === 0) console.warn('No requiredCustom found in message', { matchedRequiredCustom });
// if (matchedIgnored.length > 0) console.warn('Message contains ignored keywords', { matchedIgnored });
// MAIN gating condition:
// require at least one of the groups (G or D or C), and reject if ignore matched or a global checkpass lock is enabled
if ((!hasRequiredG && !hasRequiredD && !hasRequiredC && !hasRequiredCustom) || hasIgnoreKeyword || __checkpass__ || pleasewait) {
// Do not mark as fully processed if pleasewait or temporary condition -- allow re-check later
// Only mark as processed if it contains ignore keywords (we will never process these) to avoid re-checking forever:
if (hasIgnoreKeyword) {
processedMessageIds.add(messageId); // never process ignored messages again
}
// If it's a one-off temporary skip (pleasewait/__checkpass__), do not add to processedMessageIds so it will be retried
console.debug('Skipping message for now (gating/ignore/lock):', { hasRequiredG, hasRequiredD, hasRequiredC, hasRequiredCustom, hasIgnoreKeyword, __checkpass__, pleasewait, messageId });
// ensure pleasewait is false to prevent blocking
pleasewait = false;
return;
}
// find roblox link anchors inside message
const links = messageReal.querySelectorAll('a[href]');
// improved permissive roblox regex (handles long codes, query params)
const robloxLinkRegex = /https?:\/\/(?:www\.)?roblox\.com\/(?:games\/\d+\/[^\s?\/]+(?:\?[^ \s]*)?|share\?code=[A-Za-z0-9_-]+)/i;
const robloxLinks = Array.from(links).filter(link => robloxLinkRegex.test(link.href));
if (robloxLinks.length === 0) {
// no link found — mark as processed to avoid infinite retries
processedMessageIds.add(messageId);
console.debug('No roblox links found in latest message; marking processed', messageId);
return;
}
// only handle single-link messages (keeps behavior consistent)
if (robloxLinks.length === 1) {
// decide which mode from matched keywords
if (hasRequiredG && !glitchenabled) { logBox("ignored glitch because it is turned off"); processedMessageIds.add(messageId); return; }
if (hasRequiredD && !dreamspaceenabled) { logBox("ignored dreamspace because it is turned off"); processedMessageIds.add(messageId); return; }
if (hasRequiredC && !cyberspaceenabled) { logBox("ignored cyberspace because it is turned off"); processedMessageIds.add(messageId); return; }
if (hasRequiredCustom && !customenabled) { logBox("ignored message containing custom keywords"); processedMessageIds.add(messageId); return; }
// OK, process it
__checkpass__ = true;
const originalLink = robloxLinks[0].href;
// improved convertToDeeplink
const convertToDeeplink = (link) => {
const shareRegex = /https?:\/\/(?:www\.)?roblox\.com\/share\?code=([^&\s]+)/i;
const gamesRegex = /https?:\/\/(?:www\.)?roblox\.com\/games\/(\d+)\/[^\s?]+(?:\?[^ ]*privateServerLinkCode=([^&\s]+))?/i;
let m = link.match(shareRegex);
if (m) return `roblox://navigation/share_links?code=${m[1]}&type=Server&pid=share&is_retargeting=true`;
m = link.match(gamesRegex);
if (m) {
const placeId = m[1];
const linkCode = m[2] || '';
return linkCode ? `roblox://placeID=${placeId}&linkCode=${linkCode}` : `roblox://placeID=${placeId}`;
}
return null;
};
const deeplink = convertToDeeplink(originalLink);
if (deeplink) {
// rewrite and launch
robloxLinks[0].href = deeplink;
robloxLinks[0].textContent = deeplink;
// open in client
window.open(deeplink, '_self');
logBox(`Launched in client`);
audio.play().catch(err => console.warn("Audio failed:", err));
// mark message as processed so we don't reopen it again
processedMessageIds.add(messageId);
// short cooldown before allowing another processed message
setTimeout(() => { __checkpass__ = false; }, 3000);
return;
} else {
console.error('Failed to convert link to deeplink:', originalLink);
// mark processed so we don't spam
processedMessageIds.add(messageId);
__checkpass__ = false;
return;
}
} else {
// multiple links - skip and mark processed
processedMessageIds.add(messageId);
console.debug('Multiple roblox links found; skipping', messageId);
return;
}
}
init();
})();