-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
156 lines (135 loc) · 5.42 KB
/
Copy pathscript.js
File metadata and controls
156 lines (135 loc) · 5.42 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
document.addEventListener('DOMContentLoaded', () => {
const secretTrigger = document.getElementById('secretTrigger');
const cheatWidget = document.getElementById('cheatWidget');
const closeBtn = document.getElementById('closeBtn');
const minBtn = document.getElementById('minBtn');
const searchInput = document.getElementById('widgetSearchInput');
const ticketList = document.getElementById('ticketList');
const widgetContent = document.querySelector('.widget-content');
// Toggle widget visibility
secretTrigger.addEventListener('click', () => {
cheatWidget.classList.toggle('active');
});
closeBtn.addEventListener('click', () => {
cheatWidget.classList.remove('active');
});
// Minimize toggle
minBtn.addEventListener('click', () => {
cheatWidget.classList.toggle('minimized');
if (cheatWidget.classList.contains('minimized')) {
widgetContent.classList.add('hidden');
minBtn.innerHTML = `
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
`; // Plus sign
} else {
widgetContent.classList.remove('hidden');
minBtn.innerHTML = `
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
`; // Minus sign
}
});
// Copy button action
ticketList.addEventListener('click', (e) => {
const copyBtn = e.target.closest('.copy-btn');
if (!copyBtn) return;
const commandText = copyBtn.previousElementSibling.textContent;
navigator.clipboard.writeText(commandText).then(() => {
const originalHTML = copyBtn.innerHTML;
// Change icon to checked state
copyBtn.innerHTML = `
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#34a853" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
`;
copyBtn.classList.add('copied');
setTimeout(() => {
copyBtn.innerHTML = originalHTML;
copyBtn.classList.remove('copied');
}, 1500);
});
});
const ticketSelector = document.getElementById('ticketSelector');
// Apply both ticket selector and search text filter combined
function applyFilters() {
const query = searchInput.value.toLowerCase();
const selectedTicket = ticketSelector.value;
const items = ticketList.getElementsByClassName('ticket-item');
Array.from(items).forEach(item => {
const ticketVal = item.getAttribute('data-ticket');
const title = item.querySelector('.ticket-title').textContent.toLowerCase();
const question = item.querySelector('.ticket-question').textContent.toLowerCase();
const answer = item.querySelector('.ticket-answer').textContent.toLowerCase();
const matchesSearch = title.includes(query) || question.includes(query) || answer.includes(query);
const matchesSelector = selectedTicket === 'all' || ticketVal === selectedTicket;
if (matchesSearch && matchesSelector) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
}
// Filter triggers
searchInput.addEventListener('input', applyFilters);
ticketSelector.addEventListener('change', applyFilters);
// Make Widget Draggable
dragElement(cheatWidget);
function dragElement(elmnt) {
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
const dragHeader = elmnt.querySelector('.widget-header');
if (dragHeader) {
dragHeader.onmousedown = dragMouseDown;
} else {
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
// Check if clicked inside window buttons or search
if (e.target.closest('.control-btn') || e.target.closest('.widget-search')) {
return;
}
e.preventDefault();
// Get the mouse cursor position at startup
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// Call a function whenever the cursor moves
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// Calculate the new cursor position
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// Calculate new position
let newTop = elmnt.offsetTop - pos2;
let newLeft = elmnt.offsetLeft - pos1;
// Constrain position to screen boundaries
if (newTop < 0) newTop = 0;
if (newLeft < 0) newLeft = 0;
if (newTop + elmnt.offsetHeight > window.innerHeight) {
newTop = window.innerHeight - elmnt.offsetHeight;
}
if (newLeft + elmnt.offsetWidth > window.innerWidth) {
newLeft = window.innerWidth - elmnt.offsetWidth;
}
// Apply coordinates (disable bottom/right default alignments if set)
elmnt.style.bottom = 'auto';
elmnt.style.right = 'auto';
elmnt.style.top = newTop + "px";
elmnt.style.left = newLeft + "px";
}
function closeDragElement() {
// Stop moving when mouse button is released
document.onmouseup = null;
document.onmousemove = null;
}
}
});