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

View File

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

6
pnpm-lock.yaml generated
View File

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

View File

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