Skip to content

Commit

Permalink
little changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sandstone991 committed Aug 31, 2023
1 parent ecbaf85 commit cd05af7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 7 additions & 6 deletions source/Background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions source/Constants/index.ts
Original file line number Diff line number Diff line change
@@ -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/',

};

Expand Down
1 change: 0 additions & 1 deletion source/ContentScript/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
console.log('helloworld from content script');

export {};

0 comments on commit cd05af7

Please sign in to comment.