mirror of
https://github.com/FoxRefire/wvg.git
synced 2024-12-21 10:27:55 +00:00
Refactor:Align indent
This commit is contained in:
parent
e0d6e3079e
commit
4237a5bb60
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} )()
|
||||
|
||||
|
42
content.js
42
content.js
@ -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
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user