From cd05af78fada10ecb57f488a32148b9beba7fd68 Mon Sep 17 00:00:00 2001 From: sandstone991 Date: Thu, 31 Aug 2023 15:31:20 +0300 Subject: [PATCH] little changes --- source/Background/index.ts | 13 +++++++------ source/Constants/index.ts | 3 +-- source/ContentScript/index.ts | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/source/Background/index.ts b/source/Background/index.ts index a074f19..9777d0d 100644 --- a/source/Background/index.ts +++ b/source/Background/index.ts @@ -81,13 +81,14 @@ browser.webRequest.onBeforeRequest.addListener( let newUrl = ""; if(url.hostname.search("jsdelivr") !== -1){ let path = url.pathname.split("/"); - let rest = path[2]; - newUrl = `${providers[replacement]}${rest}` + let rest = path.slice(2).join("/"); + newUrl = `${"https://cdn.jsdelivr.xyz/npm/"}${rest}` + }; + if(url.hostname.search("unpkg") !== -1){ + let path = url.pathname.split("/"); + let rest = path.slice(2).join("/"); + newUrl = `${replacement}${rest}` }; - //find a replacement that is not blocked - //replace the url - - console.log(newUrl); return {redirectUrl: newUrl}; } return; diff --git a/source/Constants/index.ts b/source/Constants/index.ts index 911097a..e3f9ba9 100644 --- a/source/Constants/index.ts +++ b/source/Constants/index.ts @@ -1,7 +1,6 @@ const providers = { - jsdelivr: 'https://cdn.jsdelivr.net/npm/', + "cdn.jsdelivr": 'https://cdn.jsdelivr.net/npm/', unpkg: 'https://unpkg.com/', - cdnjs: 'https://cdnjs.cloudflare.com/ajax/libs/', }; diff --git a/source/ContentScript/index.ts b/source/ContentScript/index.ts index 214ca4a..a88f9a3 100644 --- a/source/ContentScript/index.ts +++ b/source/ContentScript/index.ts @@ -1,3 +1,2 @@ -console.log('helloworld from content script'); export {};