// ==UserScript== // @name OptiFine Download Links // @namespace zomo.dev // @match https://optifine.net/* // @version 1.0 // @description automatically grab optifine links through the ads // @downloadURL https://git.zomo.dev/zomo/browser-scripts/raw/branch/main/dist/optifine-download-links.user.js // @supportURL https://git.zomo.dev/zomo/browser-scripts/issues // @homepageURL https://git.zomo.dev/zomo/browser-scripts // ==/UserScript== var onhover = false async function getDownload(href) { let resp = await fetch(href) let text = await resp.text() let match = text.match(/ { if (downloadUrl) { a.href = downloadUrl a.innerText = 'Download' } else { a.innerText = 'Failed' if (onhover) attachFetchDownloadLink(a, ++depth) else setTimeout( () => attachFetchDownloadLink(a, ++depth), 1e3 ) } }) } } if (depth > 5) return if (onhover) { a.addEventListener('mouseover', run, { once: true }) } else { 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://') if (url) { a.href = url attachFetchDownloadLink(a) } } } }) })