Greasy Fork 还支持 简体中文。

FileCR Assistant Bypass & Helper

A script for FileCR that is capable of obtaining software download links (including 'fast download' URLs) and providing access to premium contents.

目前為 2023-11-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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 });
  }
}());