Skip to content

Commit

Permalink
Refactor: styling
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxRefire committed Oct 29, 2024
1 parent c7341ee commit 4316530
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions inject.js
Original file line number Diff line number Diff line change
@@ -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));
}

Expand All @@ -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")

}

Expand Down
3 changes: 1 addition & 2 deletions popup/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
}
Expand Down
1 change: 0 additions & 1 deletion popup/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 4316530

Please sign in to comment.