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 {};