Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticfile首页无法搜索 #638

Open
brooktran opened this issue Jul 27, 2022 · 6 comments
Open

staticfile首页无法搜索 #638

brooktran opened this issue Jul 27, 2022 · 6 comments

Comments

@brooktran
Copy link

brooktran commented Jul 27, 2022

查看浏览器请求,发现
请求地址 https://api.cdnjs.com/libraries/?search=jq
总是返回

{
  "error": true,
  "status": 404,
  "message": "Endpoint not found"
}
@youshandefeiyang
Copy link

youshandefeiyang commented Aug 1, 2022

js.zip
自己修好了,手动替换为本地js即可
jiaochen

@coader
Copy link

coader commented Aug 7, 2022

所以这个网站不维护了吗 这么多天未修复?

@getwebtools
Copy link

不维护了?

@zfhstudy
Copy link

首页没法搜索js库了,没人修复吗?

@zfhstudy
Copy link

js.zip 自己修好了,手动替换为本地js即可 jiaochen jiaochen

确实映射本地后可以使用

@yiyingcanfeng
Copy link

yiyingcanfeng commented Sep 19, 2022

写了个油猴脚本,可以暂时解决一下搜索的问题

// ==UserScript==
// @name         staticfile搜索优化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://staticfile.org*
// @icon         http://staticfile.org/assets/images/logo.png
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  var realFetch = "_rfetch";
  window[realFetch] = window[realFetch] || fetch;

  window.fetch = function (input, init = {}) {
    if (input.startsWith('https://api.cdnjs.com/libraries/?')) {
      input = input.replaceAll('https://api.cdnjs.com/libraries/?', 'https://api.cdnjs.com/libraries?');
    }
    return new Promise(function (resolve, reject) {
      window[realFetch](input, init).then(res => {
        const [progressStream, returnStream] = res.body.tee()
        const origRes = new Response(
          returnStream,
          {
            headers: res.headers,
            status: res.status,
            statusText: res.statusText
          })
        resolve(origRes)
      }).catch(err => {
        reject(err);
      })
    })
  }

})();

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants