mirror of
https://github.com/FoxRefire/wvg.git
synced 2024-12-22 02:48:46 +00:00
Refactor: styling
This commit is contained in:
parent
c7341ee1a4
commit
4316530ce8
10
inject.js
10
inject.js
@ -1,13 +1,13 @@
|
||||
// Refactored conversion functions
|
||||
const fromHexString = hexString => Uint8Array.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
const hexStrToU8 = hexString => Uint8Array.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
|
||||
|
||||
const toHexString = bytes => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
||||
const u8ToHexStr = bytes => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
||||
|
||||
const b64ToHex = b64 => [...atob(b64)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0)).join``
|
||||
const b64ToHexStr = b64 => [...atob(b64)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0)).join``
|
||||
|
||||
// initData to PSSH
|
||||
function getPssh(buffer) {
|
||||
const bytes = fromHexString(toHexString(new Uint8Array(buffer)).match(/000000..70737368.*/)[0]);
|
||||
const bytes = hexStrToU8(u8ToHexStr(new Uint8Array(buffer)).match(/000000..70737368.*/)[0]);
|
||||
return window.btoa(String.fromCharCode(...bytes));
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ function getClearkey(response) {
|
||||
let obj=JSON.parse((new TextDecoder("utf-8")).decode(response))
|
||||
obj = obj["keys"].map(o => [o["kid"], o["k"]]);
|
||||
obj = obj.map(o => o.map(a => a.replace(/-/g, '+').replace(/_/g, '/')+"=="))
|
||||
return obj.map(o => `${b64ToHex(o[0])}:${b64ToHex(o[1])}`).join("\n")
|
||||
return obj.map(o => `${b64ToHexStr(o[0])}:${b64ToHexStr(o[1])}`).join("\n")
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,9 @@ function showHistory(){
|
||||
function saveHistory(){
|
||||
chrome.storage.local.get(null, (data => {
|
||||
let blob = new Blob([JSON.stringify(data, null, "\t")], {type: "text/plain"});
|
||||
let blobLink = URL.createObjectURL(blob);
|
||||
let a = document.createElement('a');
|
||||
a.download = 'wvgHistory.json';
|
||||
a.href = blobLink
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.click();
|
||||
}));
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ if (clearkey) {
|
||||
document.getElementById('ckHome').style.display = 'grid';
|
||||
document.getElementById('ckResult').value = clearkey;
|
||||
document.getElementById('ckResult').addEventListener("click", copyResult);
|
||||
document.getElementById('toggleHistory').style.display = 'none'
|
||||
} else if (psshs.length) {
|
||||
document.getElementById('noEME').style.display = 'none';
|
||||
document.getElementById('home').style.display = 'grid';
|
||||
|
Loading…
Reference in New Issue
Block a user