介绍

功能:
部署在 CloudFlare Workers的小程序。
可以将 Google Drive 文件以目录形式列出,并直连下载。
流量走 CloudFlare ,网速由 CloudFlare 决定。

Demo:
https://index.gd.workers.dev/
项目地址:
https://github.com/donwa/goindex <---部署教程

特点:
1、免费。
2、直链。
3、免番。

限制:
wokers一天10万请求限制
google drive 下载10T/24h(大佬说的)
google api 调用限制

此为预览版,代码没做容错和缓存,仅做测试使用,欢迎在github上反馈。
请勿滥用。请勿滥用。请勿滥用。

//----------------------
Q&A
1、关于目录ID
打开团队盘(或文件夹或别人共享的文件夹),看地址栏。
https://drive.google.com/drive/folders/{这后面一堆代码就是id}
留空是根目录。

2、关于绑定域名
可以绑定自己的域名。操作看这个
https://github.com/donwa/goindex/issues/4

安装运行

1、访问https://install.gd.workers.dev/
2、授权认证后,生成部署代码。
3、复制代码 到 CloudFlare 部署。

安装问题域名超长QQ截图20190906190355.pngQQ截图20190906190502.png
解决方法绑定自己的域名或者重新注册短一点的域名

添加http密码

Z2Q6ZXhhbXBsZQ==为BASE64加密格式为gd:example帐号:密码
下面代码添加到var authConfig{}之后


/** http basic auth **/
// https://tool.oschina.net/encrypt?type=3
// gd:example
const authorization = "Basic Z2Q6ZXhhbXBsZQ==";
/** http basic auth **/

var gd;

addEventListener('fetch', event => {
  console.log(event.request.headers.get("Authorization"));
  if (event.request.headers.get("Authorization") !== authorization) {
    return event.respondWith(new Response(
      null, {
        status: 401,
        statusText: "'Authentication required.'",
        body: "Unauthorized",
        headers: {
          "WWW-Authenticate": 'Basic realm="User Visible Realm"'
        }
      }
    ))
  }
  event.respondWith(handleRequest(event.request))
})

添加MP4在线播放

下面代码添加到</body>标签之前

 <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/layer/2.3/layer.js"></script>
    <script>
    $(function () {
        $('.file a').each(function() {
          $(this).on('click', function() {
              if(this.href.lastIndexOf(".mp4") > 1) {
                layer.open({
                  type: 1,
                  title: decodeURI(this.href.substring(this.href.lastIndexOf("/") + 1, this.href.length)),
                  shadeClose: true,
                  shade: 0.8,
                  area: ['100%', '100%'],
                  content: '<center><video controls autoplay=true preload=auto style="width:80%;object-fit: cover;" src="' + this.href + '"></video></center>'
                });
                return false;
              }
          });
      });
    });
    </script>

自定义域名解析

域名设置cf接入
QQ截图20190906192457.png
Route填www.xxx.com/*
Worker选择你的项目名

如果觉得我的文章对你有用,请随意赞赏