From 441db3a1f45be976d2d6844cca4c85757b3dbf37 Mon Sep 17 00:00:00 2001 From: James Feng Cao Date: Fri, 7 Apr 2023 18:07:09 +0800 Subject: [PATCH] add workers for bingAI --- en/adblock_domain/index.html | 6 +++--- en/searchurl/cloudflare/bing.js | 29 +++++++++++++++++++++++++++++ en/sitemap.xml | 10 +++++----- sitemap.xml | 2 +- 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 en/searchurl/cloudflare/bing.js diff --git a/en/adblock_domain/index.html b/en/adblock_domain/index.html index 4e00805..0aad1b0 100644 --- a/en/adblock_domain/index.html +++ b/en/adblock_domain/index.html @@ -69,12 +69,12 @@
  • response headers, separeded by ';', Ex.:
    -Access-Control-Allow-Origin;*;Access-Control-Allow-Credentials;true mybing2.xn--xyza.top

    +Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true mybing.xn--xyza.top

    which makes "mybing2.xn--xyza.top" to accept CORS requests with cookies.

  • IP address and response headers, separeded by ';', Ex.:
    -172.64.80.1;Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true wild-cake-ff77.jamesfengcao.workers.dev

    +104.21.8.195;Access-Control-Allow-Origin;https://www.bing.com;Access-Control-Allow-Credentials;true uweb.torapp.eu.org

  • "default.hosts" blocks whole domain trees including all descedant domains. The domains in the hosts file must be 2 or 3 segment domains, such as "yahoo.com" and "finance.yahoo.com". If the length of the last 2 segments is less than 7, such as "com.pl", then it is treated as one segment, so domains like "xxx.xxx.com.pl" are also valid in the hosts file.

    @@ -84,7 +84,7 @@ The first part [rootDomain] is required and the others are optional. regex is ja

    Last Modified: 7 April 2023
    -hosts to support both ip address and response headers
    +add cloudflare/bing.js

    
     

    diff --git a/en/searchurl/cloudflare/bing.js b/en/searchurl/cloudflare/bing.js new file mode 100644 index 0000000..01a4711 --- /dev/null +++ b/en/searchurl/cloudflare/bing.js @@ -0,0 +1,29 @@ +export default { + async fetch(req, _env) { + let url = req.url; + let iSlash = url.indexOf('/',11); + let nUrl = "https://www.bing.com/"+url.substring(iSlash+1); + return goUrl(req, nUrl); + } +} + +function goUrl(request, url) { + //构建 fetch 参数 + let fp = { + method: request.method, + headers: {} + } + //保留头部信息 + let reqHeaders = new Headers(request.headers); + let dropHeaders = ["cookie","user-agent","accept","accept-language"]; + let he = reqHeaders.entries(); + for (let h of he) { + let key = h[0], + value = h[1]; + if (dropHeaders.includes(key)) { + fp.headers[key] = value; + } + } + return fetch(url, fp); +} + diff --git a/en/sitemap.xml b/en/sitemap.xml index 769370d..f96c5fe 100644 --- a/en/sitemap.xml +++ b/en/sitemap.xml @@ -3,7 +3,7 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml"> /en/_posts/ - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00 /en/ - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00 /en/tags/adblock/ - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00 /en/adblock_domain/ - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00 /en/tags/ - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00 en/sitemap.xml - 2023-04-07T15:29:47+08:00 + 2023-04-07T18:05:06+08:00