Skip to content

Commit 4316530

Browse files
committed
Refactor: styling
1 parent c7341ee commit 4316530

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

inject.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Refactored conversion functions
2-
const fromHexString = hexString => Uint8Array.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
2+
const hexStrToU8 = hexString => Uint8Array.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
33

4-
const toHexString = bytes => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
4+
const u8ToHexStr = bytes => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
55

6-
const b64ToHex = b64 => [...atob(b64)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0)).join``
6+
const b64ToHexStr = b64 => [...atob(b64)].map(c=> c.charCodeAt(0).toString(16).padStart(2,0)).join``
77

88
// initData to PSSH
99
function getPssh(buffer) {
10-
const bytes = fromHexString(toHexString(new Uint8Array(buffer)).match(/000000..70737368.*/)[0]);
10+
const bytes = hexStrToU8(u8ToHexStr(new Uint8Array(buffer)).match(/000000..70737368.*/)[0]);
1111
return window.btoa(String.fromCharCode(...bytes));
1212
}
1313

@@ -16,7 +16,7 @@ function getClearkey(response) {
1616
let obj=JSON.parse((new TextDecoder("utf-8")).decode(response))
1717
obj = obj["keys"].map(o => [o["kid"], o["k"]]);
1818
obj = obj.map(o => o.map(a => a.replace(/-/g, '+').replace(/_/g, '/')+"=="))
19-
return obj.map(o => `${b64ToHex(o[0])}:${b64ToHex(o[1])}`).join("\n")
19+
return obj.map(o => `${b64ToHexStr(o[0])}:${b64ToHexStr(o[1])}`).join("\n")
2020

2121
}
2222

popup/history.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ function showHistory(){
99
function saveHistory(){
1010
chrome.storage.local.get(null, (data => {
1111
let blob = new Blob([JSON.stringify(data, null, "\t")], {type: "text/plain"});
12-
let blobLink = URL.createObjectURL(blob);
1312
let a = document.createElement('a');
1413
a.download = 'wvgHistory.json';
15-
a.href = blobLink
14+
a.href = URL.createObjectURL(blob);
1615
a.click();
1716
}));
1817
}

popup/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ if (clearkey) {
7878
document.getElementById('ckHome').style.display = 'grid';
7979
document.getElementById('ckResult').value = clearkey;
8080
document.getElementById('ckResult').addEventListener("click", copyResult);
81-
document.getElementById('toggleHistory').style.display = 'none'
8281
} else if (psshs.length) {
8382
document.getElementById('noEME').style.display = 'none';
8483
document.getElementById('home').style.display = 'grid';

0 commit comments

Comments
 (0)