Skip to content

Commit

Permalink
Refactor:Align indent
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxRefire committed Jun 25, 2024
1 parent e0d6e30 commit 4237a5b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
48 changes: 24 additions & 24 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ chrome.webRequest.onBeforeSendHeaders.addListener(

//Get requestBody from POST requests
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (details.method === "POST") {
window.bodys.push({
body:details.requestBody.raw ? btoa(String.fromCharCode(...new Uint8Array(details.requestBody.raw[0]['bytes']))) : "",
id:details.requestId
});
}
},
{urls: ["<all_urls>"]},
["requestBody"]
function(details) {
if (details.method === "POST") {
window.bodys.push({
body:details.requestBody.raw ? btoa(String.fromCharCode(...new Uint8Array(details.requestBody.raw[0]['bytes']))) : "",
id:details.requestId
});
}
},
{urls: ["<all_urls>"]},
["requestBody"]
);

//Receive PSSH from content.js
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
switch(request.type){
case "RESET":
location.reload()
break;
case "PSSH":
window.psshs.push(request.text)
window.pageURL=sender.tab.url
window.targetIds=[sender.tab.id, sender.frameId]
break;
case "CLEARKEY":
window.clearkey=request.text
break;
function (request, sender, sendResponse) {
switch(request.type){
case "RESET":
location.reload()
break;
case "PSSH":
window.psshs.push(request.text)
window.pageURL=sender.tab.url
window.targetIds=[sender.tab.id, sender.frameId]
break;
case "CLEARKEY":
window.clearkey=request.text
break;
}
}
}
);
} )()

Expand Down
42 changes: 21 additions & 21 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@ if (window === window.parent){

//Send PSSH into background.js
document.addEventListener('pssh', (e) => {
chrome.runtime.sendMessage({
type: "PSSH",
text: e.detail
},null);
chrome.runtime.sendMessage({
type: "PSSH",
text: e.detail
},null);
});

//Send Clearkey into background.js
document.addEventListener('clearkey', (e) => {
chrome.runtime.sendMessage({
type: "CLEARKEY",
text: e.detail
},null);
chrome.runtime.sendMessage({
type: "CLEARKEY",
text: e.detail
},null);
});

//Fetch from original origin
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if(request.type=="FETCH"){
let res = fetch(request.u, {
method: request.m,
headers: JSON.parse(request.h),
body: Uint8Array.from(atob(request.b), c => c.charCodeAt(0))
}).then((r)=>r.arrayBuffer()).then((r)=>{
sendResponse(
btoa(String.fromCharCode(...new Uint8Array(r)))
);
})
function (request, sender, sendResponse) {
if(request.type=="FETCH"){
let res = fetch(request.u, {
method: request.m,
headers: JSON.parse(request.h),
body: Uint8Array.from(atob(request.b), c => c.charCodeAt(0))
}).then((r)=>r.arrayBuffer()).then((r)=>{
sendResponse(
btoa(String.fromCharCode(...new Uint8Array(r)))
);
})
}
return true
}
return true
}
);

0 comments on commit 4237a5b

Please sign in to comment.