staticfile / static

开放静态文件 - 为开源库提供稳定、快速的免费 CDN 服务
https://staticfile.org
Other
1.41k stars 521 forks source link

搜索不了了 #632

Open anyforever opened 2 years ago

anyforever commented 2 years ago

RT

maxsky commented 2 years ago

+1

anyforever commented 2 years ago

被墙了,设定一下DNS解析,这个可以用 104.24.177.7 api.cdnjs.com @maxsky

maxsky commented 2 years ago

被墙了,设定一下DNS解析,这个可以用 104.24.177.7 api.cdnjs.com @maxsky

3Q

yeliping commented 2 years ago

有时可以,有时不可以

getwebtools commented 2 years ago

2个多月了这个搜索问题还没解决,网站是废弃了么

yiyingcanfeng commented 2 years ago

2个多月了这个搜索问题还没解决,网站是废弃了么

主页搜索用不了的话,可以用下面的油猴脚本解决,不过只能解决网站请求api.cdnjs.com的404错误,api.cdnjs.com被墙的话就没办法了

// ==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