updated browser-scripts-builder

This commit is contained in:
2022-06-09 11:10:33 -05:00
parent 6082836470
commit 3239443a6c
4 changed files with 68 additions and 59 deletions

View File

@@ -8,55 +8,56 @@
// @supportURL https://git.zomo.dev/zomo/browser-scripts/issues
// @homepageURL https://git.zomo.dev/zomo/browser-scripts
// ==/UserScript==
var onhover = false;
var onhover = false
async function getDownload(href) {
let resp = await fetch(href);
let text = await resp.text();
let match = text.match(/<a href=['"](downloadx.*?)['"]/i);
let resp = await fetch(href)
let text = await resp.text()
let match = text.match(/<a href=['"](downloadx.*?)['"]/i)
if (match) {
return match[1];
return match[1]
}
return null;
return null
}
function attachFetchDownloadLink(a, depth = 0) {
function run() {
a.innerText = "Loading";
let url = new URL(a.href);
if (url.pathname === "/adloadx") {
getDownload(a.href).then((downloadUrl) => {
a.innerText = 'Loading'
let url = new URL(a.href)
if (url.pathname === '/adloadx') {
getDownload(a.href).then(downloadUrl => {
if (downloadUrl) {
a.href = downloadUrl;
a.innerText = "Download";
a.href = downloadUrl
a.innerText = 'Download'
} else {
a.innerText = "Failed";
if (onhover)
attachFetchDownloadLink(a, ++depth);
a.innerText = 'Failed'
if (onhover) attachFetchDownloadLink(a, ++depth)
else
setTimeout(() => attachFetchDownloadLink(a, ++depth), 1e3);
setTimeout(
() => attachFetchDownloadLink(a, ++depth),
1e3
)
}
});
})
}
}
if (depth > 5)
return;
if (depth > 5) return
if (onhover) {
a.addEventListener("mouseover", run, { once: true });
a.addEventListener('mouseover', run, { once: true })
} else {
run();
run()
}
}
addEventListener("load", () => {
document.querySelectorAll("a").forEach((a) => {
let href = new URL(a.href);
if (href.hostname === "adfoc.us") {
let params = href.searchParams;
if (params.has("url")) {
let url = params.get("url")?.replace("http://", "https://");
addEventListener('load', () => {
document.querySelectorAll('a').forEach(a => {
let href = new URL(a.href)
if (href.hostname === 'adfoc.us') {
let params = href.searchParams
if (params.has('url')) {
let url = params.get('url')?.replace('http://', 'https://')
if (url) {
a.href = url;
attachFetchDownloadLink(a);
a.href = url
attachFetchDownloadLink(a)
}
}
}
});
});
})
})

View File

@@ -8,14 +8,18 @@
// @supportURL https://git.zomo.dev/zomo/browser-scripts/issues
// @homepageURL https://git.zomo.dev/zomo/browser-scripts
// ==/UserScript==
addEventListener("load", () => {
document.body.addEventListener("click", (e) => {
let target = e.target;
if (target && target.getAttribute("data-a-target") === "player-overlay-click-handler") {
let video = document.querySelector("video");
addEventListener('load', () => {
document.body.addEventListener('click', e => {
let target = e.target
if (
target &&
target.getAttribute('data-a-target') ===
'player-overlay-click-handler'
) {
let video = document.querySelector('video')
if (video) {
video.muted = !video.muted;
video.muted = !video.muted
}
}
});
});
})
})

6
pnpm-lock.yaml generated
View File

@@ -9,7 +9,7 @@ specifiers:
devDependencies:
'@types/greasemonkey': 4.0.3
browser-scripts-builder: git.zomo.dev/zomo/browser-scripts-builder/57f75997398f9685504bbb1eb5f24ab99394ac3b
browser-scripts-builder: git.zomo.dev/zomo/browser-scripts-builder/e8de01b48a8c3f4314ad8e08d19b7535d4c41f2a
eslint: 8.17.0
prettier: 2.6.2
typescript: 4.7.3
@@ -818,8 +818,8 @@ packages:
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
dev: true
git.zomo.dev/zomo/browser-scripts-builder/57f75997398f9685504bbb1eb5f24ab99394ac3b:
resolution: {commit: 57f75997398f9685504bbb1eb5f24ab99394ac3b, repo: ssh://git@git.zomo.dev/zomo/browser-scripts-builder.git, type: git}
git.zomo.dev/zomo/browser-scripts-builder/e8de01b48a8c3f4314ad8e08d19b7535d4c41f2a:
resolution: {commit: e8de01b48a8c3f4314ad8e08d19b7535d4c41f2a, repo: ssh://git@git.zomo.dev/zomo/browser-scripts-builder.git, type: git}
name: browser-scripts-builder
version: 1.0.0
hasBin: true

View File

@@ -1,5 +1,9 @@
# browser-scripts
## To Do
- [prettier](https://prettier.io/docs/en/api.html) after building
<!-- START INSTALL LINKS -->
## Installs