Skip to content

Commit acb5a11

Browse files
Merge branch 'dev' into feat/youglish_search
2 parents 628ca2a + 822de84 commit acb5a11

18 files changed

+1764
-636
lines changed

popup/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
viewScriptSource,
4040
} from "./helpers/utils.js";
4141
import { checkPass } from "../scripts/auto_lockWebsite.js";
42-
import _ from "../md/exportScriptsToMd.js";
42+
// import _ from "../md/exportScriptsToMd.js";
4343

4444
const settingsBtn = document.querySelector(".settings");
4545
const openInNewTabBtn = document.querySelector(".open-in-newtab");

popup/tabs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const tabs = [
3636
{
3737
...CATEGORY.search,
3838
scripts: [
39-
// s._test,
39+
s._test,
4040
// s._ufs_statistic,
4141
s.similarWeb,
4242
s.similarWeb_bypassLimit,
@@ -498,9 +498,10 @@ const tabs = [
498498
{
499499
...CATEGORY.youtube,
500500
scripts: [
501-
// s.youtube_localDownloader,
502501
s.youtube_downloadVideo,
503502
s.youtube_downloadVideoUI,
503+
s.youtube_getVideoThumbnail,
504+
s.youtube_getVideoCaption,
504505
s.youtube_toggleLight,
505506
s.pictureInPicture,
506507
s.pip_fullWebsite,

scripts/_index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export { default as vuiz_createLogo } from "./vuiz_createLogo.js";
131131
export { default as vuiz_getLink } from "./vuiz_getLink.js";
132132
export { default as ggdrive_downloadPdf } from "./ggdrive_downloadPdf.js";
133133
export { default as ggdrive_downloadPresentation } from "./ggdrive_downloadPresentation.js";
134-
export { default as youtube_localDownloader } from "./youtube_localDownloader.js";
135134
export { default as twitter_downloadButton } from "./twitter_downloadButton.js";
136135
export { default as spotify_downloadButton } from "./spotify_downloadButton.js";
137136
export { default as ggdrive_downloadDoc } from "./ggdrive_downloadDoc.js";
@@ -170,3 +169,5 @@ export { default as fb_getPostReactionCount } from "./fb_getPostReactionCount.js
170169
export { default as bypass_learnAnything } from "./bypass_learnAnything.js";
171170
export { default as youtube_downloadVideoUI } from "./youtube_downloadVideoUI.js";
172171
export { default as youglish_search } from "./youglish_search.js";
172+
export { default as youtube_getVideoThumbnail } from "./youtube_getVideoThumbnail.js";
173+
export { default as youtube_getVideoCaption } from "./youtube_getVideoCaption.js";

scripts/_test.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { UfsGlobal } from "./content-scripts/ufs_global.js";
2+
import { fetchGraphQl, getFbdtsg } from "./fb_GLOBAL.js";
23

34
export default {
45
icon: "",
@@ -12,6 +13,79 @@ export default {
1213
},
1314

1415
popupScript: {
16+
onClick: async () => {
17+
function getAverageRGB(img) {
18+
var blockSize = 5, // only visit every 5 pixels
19+
defaultRGB = { r: 0, g: 0, b: 0 }, // for non-supporting envs
20+
canvas = document.createElement("canvas"),
21+
context = canvas.getContext && canvas.getContext("2d"),
22+
data,
23+
width,
24+
height,
25+
i = -4,
26+
length,
27+
rgb = { r: 0, g: 0, b: 0 },
28+
count = 0;
29+
30+
if (!context) {
31+
return defaultRGB;
32+
}
33+
34+
height = canvas.height =
35+
img.naturalHeight || img.offsetHeight || img.height;
36+
width = canvas.width = img.naturalWidth || img.offsetWidth || img.width;
37+
38+
context.drawImage(img, 0, 0);
39+
40+
try {
41+
data = context.getImageData(0, 0, width, height);
42+
} catch (e) {
43+
/* security error, img on diff domain */
44+
return defaultRGB;
45+
}
46+
47+
length = data.data.length;
48+
49+
while ((i += blockSize * 4) < length) {
50+
++count;
51+
rgb.r += data.data[i];
52+
rgb.g += data.data[i + 1];
53+
rgb.b += data.data[i + 2];
54+
}
55+
56+
// ~~ used to floor values
57+
rgb.r = ~~(rgb.r / count);
58+
rgb.g = ~~(rgb.g / count);
59+
rgb.b = ~~(rgb.b / count);
60+
61+
return rgb;
62+
}
63+
64+
function getAverageRGBFromUrl(url) {
65+
return new Promise((resolve, reject) => {
66+
let img = new Image();
67+
img.src = url;
68+
img.onload = () => {
69+
let rgb = getAverageRGB(img);
70+
resolve(rgb);
71+
};
72+
img.onerror = (error) => {
73+
alert("Error: " + JSON.stringify(error));
74+
console.log(error);
75+
reject();
76+
};
77+
});
78+
}
79+
80+
getAverageRGBFromUrl(
81+
"https://scontent.fsgn2-7.fna.fbcdn.net/v/t39.30808-1/352545274_2285354618338828_3224207586206963955_n.jpg?stp=dst-jpg_p480x480&ccb=1-7&_nc_sid=0ecb9b&_nc_ohc=7D3Usqt8u2UQ7kNvgEeWxht&_nc_ht=scontent.fsgn2-7.fna&oh=00_AYAeunf-6BuCakj2L59wVi8mNA5QuGlLuVQ6eROL5UKC8A&oe=668D93B9"
82+
).then(console.log);
83+
84+
getAverageRGBFromUrl(
85+
"https://www.facebook.com/profile/pic.php?cuid=AYjse6TURBs86Oy-7iO2UdCZFqYOhyemrWC2KV8yPo6ABGAHCWi87GNGtXwITHZJRPIOPLMTbuZetu6t3T9WQllYE5xhBm4t5rAZVKC1IGjSqGbJiwr9z4g-bDx6bHAPuqqXgfCaH4Yml-_UAAJgEGdftXSGc4uCKUer8j3oCtpLakjxWAOTYeNAzt-rWWp0fNtY03PE0XzLzPqKEI8leoS_08eYd_V9L4O_P1lwGxHyMA&square_px=64"
86+
).then(console.log);
87+
},
88+
1589
// selenium automation get album's images
1690
_onClick: async () => {
1791
const { openWebAndRunScript } = await import("./helpers/utils.js");

scripts/_ufs_statistic.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ canvas {
99
max-height: 500px;
1010
}
1111

12+
li {
13+
position: relative;
14+
}
15+
1216
li:hover {
1317
background: #555;
1418
color: white;
1519
}
1620

1721
li a {
1822
display: inline-block;
19-
position: relative;
2023
}
2124

2225
li a img {
2326
width: 30px;
2427
transition: all 0.2s ease;
2528
position: absolute;
26-
left: 0;
29+
right: 0;
2730
top: 0;
2831
}
2932

scripts/backup/auto-like-fb.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
javascript: (async function () {
2+
function sleep(ms) {
3+
return new Promise((resolve) => setTimeout(resolve, ms));
4+
}
5+
function focusTo(element) {
6+
element.dispatchEvent(
7+
new MouseEvent("pointerover", {
8+
view: window,
9+
bubbles: true,
10+
cancelable: true,
11+
})
12+
);
13+
}
14+
15+
function scrollToBottom() {
16+
window.scrollTo(0, document.body.scrollHeight, {
17+
// behavior: "smooth",
18+
});
19+
}
20+
21+
const doneKey = "auto-like-done";
22+
const btns = [];
23+
while (true) {
24+
if (!btns.length) {
25+
let curBtns = Array.from(
26+
document.querySelectorAll("[aria-label='Bày tỏ cảm xúc']:not(li *)")
27+
);
28+
let added = 0;
29+
for (let btn of curBtns) {
30+
if (btn.getAttribute(doneKey) === null) {
31+
btns.push(btn);
32+
btn.setAttribute(doneKey, true);
33+
added++;
34+
}
35+
}
36+
if (added === 0) break;
37+
}
38+
39+
for (let btn of btns) {
40+
btn.scrollIntoView({
41+
block: "center",
42+
// behavior: "smooth",
43+
});
44+
btn.click();
45+
await sleep(500);
46+
let loveBtn = document.querySelector("[aria-label='Yêu thích']");
47+
if (loveBtn) {
48+
focusTo(loveBtn);
49+
await sleep(500);
50+
loveBtn.click();
51+
await sleep(500);
52+
}
53+
btns.splice(btns.indexOf(btn), 1);
54+
}
55+
scrollToBottom();
56+
await sleep(3000);
57+
}
58+
alert("xong");
59+
})();

0 commit comments

Comments
 (0)