Skip to content

Commit d38718d

Browse files
committed
Refactor: Put popup related scripts in popup folder together
1 parent b5f0643 commit d38718d

8 files changed

+20
-20
lines changed

background.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ chrome.runtime.onMessage.addListener(
7575
chrome.browserAction.onClicked.addListener(tab => {
7676
if(chrome.windows){
7777
chrome.windows.create({
78-
url: "popup.html",
78+
url: "popup/main.html",
7979
type: "popup",
8080
width: 820,
8181
height: 600
8282
});
8383
} else {
84-
chrome.tabs.create({url: 'popup.html'})
84+
chrome.tabs.create({url: 'popup/main.html'})
8585
}
8686
});
8787

File renamed without changes.

popup.html popup/main.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta charset="UTF-8">
44
<title>Widevine L3 Guessor 2024</title>
55
<link rel="stylesheet" href="style.css">
6-
<script src="libs/pyodide/pyodide.js"></script>
6+
<script src="/libs/pyodide/pyodide.js"></script>
77
</head>
88
<body>
99
<div id="toggleHistory">
@@ -81,9 +81,9 @@ <h3>Clearkey detected</h3>
8181
<a href="https://github.com/FoxRefire/wvg/archive/=HASH=.zip">Download</a>
8282
</div>
8383
</body>
84-
<script src="popup.js" type="module"></script>
85-
<script src="popup_drawList.js"></script>
86-
<script src="libs/jsonview.js"></script>
87-
<script src="popup_showHistory.js"></script>
88-
<script src="popup_updateNotice.js"></script>
84+
<script src="./main.js" type="module"></script>
85+
<script src="./drawList.js"></script>
86+
<script src="/libs/jsonview.js"></script>
87+
<script src="./showHistory.js"></script>
88+
<script src="./updateNotice.js"></script>
8989
</html>

popup.js popup/main.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ async function guess(){
1111

1212
//Init Pyodide
1313
let pyodide = await loadPyodide();
14-
await pyodide.loadPackage(["certifi-2024.2.2-py3-none-any.whl","charset_normalizer-3.3.2-py3-none-any.whl","construct-2.8.8-py2.py3-none-any.whl","idna-3.6-py3-none-any.whl","packaging-23.2-py3-none-any.whl","protobuf-4.24.4-cp312-cp312-emscripten_3_1_52_wasm32.whl","pycryptodome-3.20.0-cp35-abi3-emscripten_3_1_52_wasm32.whl","pymp4-1.4.0-py3-none-any.whl","pyodide_http-0.2.1-py3-none-any.whl","pywidevine-1.8.0-py3-none-any.whl","requests-2.31.0-py3-none-any.whl","urllib3-2.2.1-py3-none-any.whl"].map(e=>"libs/wheels/"+e))
14+
await pyodide.loadPackage(["certifi-2024.2.2-py3-none-any.whl","charset_normalizer-3.3.2-py3-none-any.whl","construct-2.8.8-py2.py3-none-any.whl","idna-3.6-py3-none-any.whl","packaging-23.2-py3-none-any.whl","protobuf-4.24.4-cp312-cp312-emscripten_3_1_52_wasm32.whl","pycryptodome-3.20.0-cp35-abi3-emscripten_3_1_52_wasm32.whl","pymp4-1.4.0-py3-none-any.whl","pyodide_http-0.2.1-py3-none-any.whl","pywidevine-1.8.0-py3-none-any.whl","requests-2.31.0-py3-none-any.whl","urllib3-2.2.1-py3-none-any.whl"].map(e=>"/libs/wheels/"+e))
1515

1616
//Configure Guesser
1717
pyodide.globals.set("pssh", document.getElementById('pssh').value);
1818
pyodide.globals.set("licUrl", requests[userInputs['license']]['url']);
1919
pyodide.globals.set("licHeaders", requests[userInputs['license']]['headers']);
2020
pyodide.globals.set("licBody", requests[userInputs['license']]['body']);
21-
let pre=await fetch('python/pre.py').then(res=>res.text())
22-
let after=await fetch('python/after.py').then(res=>res.text())
23-
let scheme=await fetch(`python/schemes/${document.getElementById("scheme").value}.py`).then(res=>res.text())
21+
let pre=await fetch('/python/pre.py').then(res=>res.text())
22+
let after=await fetch('/python/after.py').then(res=>res.text())
23+
let scheme=await fetch(`/python/schemes/${document.getElementById("scheme").value}.py`).then(res=>res.text())
2424

2525
//Get result
2626
let result = await pyodide.runPythonAsync([pre, scheme, after].join("\n"));
@@ -52,7 +52,7 @@ window.corsFetch = (u, m, h, b) => {
5252
}
5353

5454
async function autoSelect(){
55-
let selectRules = await fetch("selectRules.conf").then((r)=>r.text());
55+
let selectRules = await fetch("/selectRules.conf").then((r)=>r.text());
5656
//Remove blank lines, comment-outs, and trailing spaces at the end of lines
5757
selectRules = selectRules.replace(/\n^\s*$|\s*\/\/.*|\s*$/gm, "");
5858
selectRules = selectRules.split("\n").map(row => row.split("$$"));
File renamed without changes.

style.css popup/style.css

File renamed without changes.

popup_updateNotice.js popup/updateNotice.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
document.addEventListener('DOMContentLoaded', async function() {
2-
cManifest=await fetch("manifest.json").then(r=>r.json());
2+
cManifest=await fetch("/manifest.json").then(r=>r.json());
33
rManifest=await fetch("https://raw.githubusercontent.com/FoxRefire/wvg/next/manifest.json").then(r=>r.json());
44
if(cManifest.version < rManifest.version){
55
let notice = document.getElementById("updateNotice");

python/pre.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ def blobsToDevice(cID, pKey):
1414
async def loadCdm():
1515
# Looking for device.wvd
1616
try:
17-
wvd = await (await pyfetch("device.wvd")).bytes()
17+
wvd = await (await pyfetch("/device.wvd")).bytes()
1818
return Cdm.from_device(Device.loads(wvd))
1919
except:
2020
pass
2121

2222
# Looking for device_client_id_blob + device_private_key
2323
try:
24-
cID=await (await pyfetch("device_client_id_blob")).bytes()
25-
pKey=await (await pyfetch("device_private_key")).bytes()
24+
cID=await (await pyfetch("/device_client_id_blob")).bytes()
25+
pKey=await (await pyfetch("/device_private_key")).bytes()
2626
return Cdm.from_device(blobsToDevice(cID, pKey))
2727
except:
2828
pass
2929

3030
# Looking for client_id.bin + private_key.pem
3131
try:
32-
cID=await (await pyfetch("client_id.bin")).bytes()
33-
pKey=await (await pyfetch("private_key.pem")).bytes()
32+
cID=await (await pyfetch("/client_id.bin")).bytes()
33+
pKey=await (await pyfetch("/private_key.pem")).bytes()
3434
return Cdm.from_device(blobsToDevice(cID, pKey))
3535
except:
3636
pass
3737

3838
# Looking for remote.json
3939
try:
40-
remote_conf=await (await pyfetch("remote.json")).json()
40+
remote_conf=await (await pyfetch("/remote.json")).json()
4141
return RemoteCdm(**remote_conf)
4242
except Exception as e:
4343
js.document.getElementById('result').value=f"No CDM key pair found! \n\n https://github.com/FoxRefire/wvg/wiki/Getting-started#2-put-cdm-key-pair-files"

0 commit comments

Comments
 (0)