A script for FileCR that is capable of obtaining software download links (including 'fast download' URLs) and providing access to premium contents.
当前为
// ==UserScript==
// @name FileCR Assistant Bypass & Helper
// @name:zh FileCR 助手
// @namespace xiakele
// @version 2.0
// @description A script for FileCR that is capable of obtaining software download links (including 'fast download' URLs) and providing access to premium contents.
// @description:zh 一键获取FileCR的软件下载链接(包括快速下载),无需拓展即可访问premium内容。
// @author xiakele
// @license MIT
// @match *://filecr.com/*
// @icon https://filecr.com/favicon.png
// @grant window.onurlchange
// ==/UserScript==
(function () {
const versionInfo = {
id: 'ddgilliopjknmglnpkegbjpoilgachlm',
version: '9.9.9',
};
if (!document.cookie.includes('extensionIsInstalled')) {
document.cookie = 'extensionIsInstalled=true;';
}
window.addEventListener(
'message',
(event) => {
const data = {
direction: 'from-content-script',
responseFor: event.data.id,
type: 'response',
};
if (event.data.action === 'app.info') {
data.data = versionInfo;
window.postMessage(data);
} else if (event.data.action === 'downloads.extractLink') {
data.data = event.data.data.url;
window.postMessage(data);
}
},
);
async function getLinks(meta) {
if (['Torrent', 'Internal'].includes(meta.type)) {
const result = {};
result.provider = meta.type;
result.url = await fetch(`/api/actions/downloadlink/?id=${meta.id}`)
.then((data) => data.json())
.then((json) => json.url);
return result;
}
const result = await fetch(`https://filecr.com/api/actions/worker/?link_id=${meta.id}`)
.then((data) => data.json())
.then((json) => ({ provider: json.download_provider, url: json.url }));
return result;
}
async function displayLinks(json) {
if (document.querySelector('#link-field')) {
return;
}
const trigger = document.querySelector('#trigger');
const div = document.createElement('div');
div.id = 'link-field';
document.querySelector('.download-info').appendChild(div);
trigger.innerText = 'Loading...';
const linksMeta = json.props.pageProps.post.downloads[0].links;
const downloadLinks = await Promise.all(linksMeta.map((meta) => getLinks(meta)));
downloadLinks.forEach((link, i) => {
const a = document.createElement('a');
a.href = link.url;
a.classList.add('link-light');
a.innerText = `Link ${i + 1} (${link.provider})\n`;
div.appendChild(a);
});
trigger.innerText = 'COMPLETE!';
}
let reloaded = false;
function addTrigger() {
if (document.querySelector('.e-404') && !reloaded) {
reloaded = true;
window.location.reload();
}
if (!document.querySelector('.download-info') || document.querySelector('#trigger')) {
return;
}
const rawJSON = JSON.parse(document.querySelector('#__NEXT_DATA__').textContent);
const a = document.createElement('a');
a.id = 'trigger';
a.innerText = 'GET DOWNLOAD LINKS';
a.classList.add('link-light');
if (!window.location.pathname.includes(rawJSON.query.postSlug)) {
a.addEventListener('click', () => window.location.reload());
a.innerText += '\n(Data mismatch. Reload is required.)';
} else {
a.addEventListener('click', () => displayLinks(rawJSON));
}
document.querySelector('.download-info').appendChild(a);
}
addTrigger();
if (window.onurlchange === null) {
window.addEventListener('urlchange', () => addTrigger());
} else {
const observer = new MutationObserver(() => addTrigger());
observer.observe(document.head, { childList: true });
}
}());