Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9fa511b

Browse files
author
hoang.tran12
committedApr 10, 2024
magnify image - WIP
1 parent 5c6738b commit 9fa511b

12 files changed

+157
-8
lines changed
 

‎popup/tabs.js

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ const tabs = [
203203
s.changeAudioOutput,
204204
s.send_shareFiles,
205205
createTitle("--- Image ---", "--- Ảnh ---"),
206+
s.magnify_image,
206207
s.screenshotFullPage,
207208
s.vuiz_createLogo,
208209
createTitle("--- Automation ---", "--- Tự động hoá ---"),

‎scripts/content-scripts/ufs_global_webpage_context.js

+28
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@ const UsefulScriptGlobalPageContext = {
3737
},
3838
},
3939
DOM: {
40+
onDoublePress(key, callback, timeout = 500) {
41+
let timer = null;
42+
let clickCount = 0;
43+
44+
const keydown = (event) => {
45+
if (event.key !== key) return;
46+
47+
clickCount++;
48+
if (clickCount === 2) {
49+
callback?.();
50+
clickCount = 0;
51+
return;
52+
}
53+
54+
clearTimeout(timer);
55+
timer = setTimeout(() => {
56+
clickCount = 0;
57+
}, timeout);
58+
};
59+
60+
document.addEventListener("keydown", keydown);
61+
62+
return () => {
63+
clearTimeout(timer);
64+
document.removeEventListener("keydown", keydown);
65+
};
66+
},
67+
4068
// https://stackoverflow.com/a/3381522
4169
createFlashTitle(newMsg, howManyTimes) {
4270
var original = document.title;

‎scripts/duckRace_cheat.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default {
1010
img: "/scripts/duckRage_cheat.png",
1111
},
1212

13-
whiteList: [],
13+
whiteList: ["https://www.online-stopwatch.com/*"],
1414

1515
onClick: () => {
1616
const target = prompt("Nhập kết quả mong muốn:", "");
@@ -24,7 +24,6 @@ export default {
2424
if (!win.ufs_duckRace_originalShuffle)
2525
win.ufs_duckRace_originalShuffle = win.Array.prototype.shuffle;
2626

27-
console.log("modify shuffle in", win);
2827
win.Array.prototype.shuffle = function () {
2928
const result = win.ufs_duckRace_originalShuffle.apply(
3029
this,
@@ -46,6 +45,3 @@ export default {
4645
});
4746
},
4847
};
49-
50-
// functions/attributes that other scripts can import and use
51-
export const shared = {};

‎scripts/duckRage_cheat.png

-228 KB
Loading

‎scripts/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ import ggdrive_downloadDoc from "./ggdrive_downloadDoc.js";
175175
import ggdrive_copyDocText from "./ggdrive_copyDocText.js";
176176
import ggdrive_copySheetText from "./ggdrive_copySheetText.js";
177177
import duckRace_cheat from "./duckRace_cheat.js";
178+
import magnify_image from "./magnify_image.js";
178179

179180
// inject badges
180181
const allScripts = {
@@ -375,6 +376,7 @@ const allScripts = {
375376
ggdrive_copyDocText: addBadge(ggdrive_copyDocText, BADGES.new),
376377
ggdrive_copySheetText: addBadge(ggdrive_copySheetText, BADGES.new),
377378
duckRace_cheat: addBadge(duckRace_cheat, BADGES.new),
379+
magnify_image: addBadge(magnify_image, BADGES.new),
378380
};
379381

380382
// alert(Object.keys(allScripts).length);

‎scripts/insta_injectDownloadBtn.png

-189 KB
Loading

‎scripts/magnify_image.js

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
export default {
2+
icon: '<i class="fa-solid fa-magnifying-glass-plus"></i>',
3+
name: {
4+
en: "Magnify Image with Ctrl",
5+
vi: "Phóng to hình ảnh bằng Ctrl",
6+
},
7+
description: {
8+
en: "Press Ctrl twice to any image to open it in magnified window",
9+
vi: "Nhấn Ctrl 2 lần lên bất kỳ hình ảnh nào để xem nó trong cửa sổ phóng đại",
10+
img: "",
11+
},
12+
13+
onDocumentStart: () => {
14+
let mouse = { x: 0, y: 0 };
15+
16+
document.addEventListener("mousemove", (e) => {
17+
mouse.x = e.clientX;
18+
mouse.y = e.clientY;
19+
});
20+
21+
function getAllElementsWithBackgroundImage() {
22+
const elements = [];
23+
const allElements = document.querySelectorAll("*"); // Select all elements
24+
25+
for (const element of allElements) {
26+
const backgroundImage =
27+
getComputedStyle(element).getPropertyValue("background-image");
28+
if (backgroundImage !== "none" && backgroundImage.match(/url\(/)) {
29+
// Check for "none" and existence of url(...) pattern
30+
elements.push(element);
31+
}
32+
}
33+
34+
return elements;
35+
}
36+
37+
let unsub = UsefulScriptGlobalPageContext.DOM.onDoublePress(
38+
"Control",
39+
() => {
40+
try {
41+
let src = Array.from(document.querySelectorAll("img"))
42+
.map((i) => ({
43+
src: i.src,
44+
rect: i.getBoundingClientRect(),
45+
}))
46+
.concat(
47+
getAllElementsWithBackgroundImage().map((i) => ({
48+
src: i.style.backgroundImage
49+
?.replace("url(", "")
50+
?.replace(")", "")
51+
?.replace('"', "")
52+
?.replace('"', ""),
53+
rect: i.getBoundingClientRect(),
54+
}))
55+
)
56+
.filter(({ src, rect }) => {
57+
return (
58+
src &&
59+
mouse.x > rect.x &&
60+
mouse.x < rect.x + rect.width &&
61+
mouse.y > rect.y &&
62+
mouse.y < rect.y + rect.height
63+
);
64+
});
65+
console.log(src);
66+
67+
src = src.sort((a, b) => {
68+
// small one first
69+
return a.rect.width * a.rect.height - b.rect.width * b.rect.height;
70+
})?.[0]?.src;
71+
72+
console.log(src);
73+
74+
if (src) {
75+
let w = 600,
76+
h = 600,
77+
left = screen.width / 2 - w / 2,
78+
top = screen.height / 2 - h / 2;
79+
80+
let win = window.open(
81+
"",
82+
"",
83+
`scrollbars=yes,width=${w},height=${h},top=${top},left=${left}`
84+
);
85+
win.document.write(`
86+
<style>
87+
html, body {
88+
margin: 0;
89+
padding: 0;
90+
width: 100%;
91+
height: 100%;
92+
background-color: #221c1c;
93+
}
94+
.magnify {
95+
box-sizing: border-box;
96+
padding: 5px 5px 0;
97+
position: absolute;
98+
text-align: center;
99+
top: 0;
100+
left: 0;
101+
overflow: hidden;
102+
width: 100%;
103+
height: 100%;
104+
transform-origin: 0px 0px;
105+
transform: scale(1) translate(0px, 0px);
106+
}
107+
</style>
108+
<div class="magnify">
109+
<img src="${src}" style="width: 500px" />
110+
</div>`);
111+
}
112+
} catch (e) {
113+
console.log("ERROR", e);
114+
}
115+
}
116+
);
117+
},
118+
};

‎scripts/soundcloud_downloadMusic.png

-24.1 KB
Loading

‎scripts/spotify_downloadButton.png

-209 KB
Loading

‎scripts/twitter_downloadButton.png

-99 KB
Loading

‎scripts/whellOfNames_hack.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export default {
55
vi: "Hack Wheel of Names",
66
},
77
description: {
8-
en: "Hack result of wheelofnames.com/wheelrandom.com/spinthewheel.io, choose your target, then result will always be your target.",
9-
vi: "Hack kết quả trang web wheelofnames.com/wheelrandom.com/spinthewheel.io, luôn ra kết quả bạn mong muốn thay vì ngẫu nhiên.",
8+
en: "Hack result of <ul><li>wheelofnames.com</li><li>wheelrandom.com</li><li>spinthewheel.io</li></ul>always get the result you want.",
9+
vi: "Hack kết quả trang web <ul><li>wheelofnames.com</li><li>wheelrandom.com</li><li>spinthewheel.io</li></ul>luôn ra kết quả bạn mong muốn.",
1010
},
1111
whiteList: [
1212
"https://wheelofnames.com/*",

‎working_note.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WORKING NOTES
22

3-
## 29/03/2024
3+
## 29/03/2024 - 10/04/2024
44

55
- [ ] fb_invisible_message có vẻ không hoạt động
66

@@ -35,3 +35,7 @@
3535
- [x] Wheel of name - input list of values
3636

3737
- [ ] duck race - input list of values
38+
39+
- [ ] fb_getAllUidOfGroupMembers đang lỗi
40+
41+
- [ ] text to qrcode <https://hoothin.com/qrcode/>

0 commit comments

Comments
 (0)
Please sign in to comment.