Skip to content

Commit

Permalink
Refactor: Separate history page from main page
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxRefire committed Oct 12, 2024
1 parent d38718d commit ec92722
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
18 changes: 18 additions & 0 deletions popup/history.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>
<meta charset="UTF-8">
<title>Widevine L3 Guessor - History</title>
<link rel="stylesheet" href="style.css">
<script src="/libs/pyodide/pyodide.js"></script>
</head>
<body>
<div id="history">
<a href="./main.html"><button>🔙 Back</button></a>
<button id="saveHistory">💾 Save History</button>
<button id="clearHistory">❌ Clear History</button>
<div id="histDisp"></div>
</div>
</body>
<script src="/libs/jsonview.js"></script>
<script src="./history.js"></script>
</html>
21 changes: 3 additions & 18 deletions popup/showHistory.js → popup/history.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
let psshs=chrome.extension.getBackgroundPage().psshs;
function showHistory(){
chrome.storage.local.get(null, ((data) => {
chrome.storage.local.get(null, (data => {
let tree=jsonview.renderJSON(JSON.stringify(data), document.getElementById('histDisp'));
jsonview.toggleNode(tree);
}));
document.getElementById('home').style.display='none';
document.getElementById('noEME').style.display='none';
document.getElementById('history').style.display='grid';
document.getElementById('toggleHistory').style.display='none';
}

function backHistory(){
document.getElementById('histDisp').innerHTML="";
document.getElementById('history').style.display='none';
document.getElementById('toggleHistory').style.display='grid';
if(psshs.length){
document.getElementById('home').style.display='grid';
} else {
document.getElementById('noEME').style.display='grid';
}
}

function saveHistory(){
Expand All @@ -41,7 +26,7 @@ function clearHistory(){
document.getElementById('histDisp').innerHTML="";
}
}
document.getElementById('historyButton').addEventListener("click", showHistory);
document.getElementById('backHistory').addEventListener("click", backHistory);

document.getElementById('saveHistory').addEventListener("click", saveHistory);
document.getElementById('clearHistory').addEventListener("click", clearHistory);
showHistory()
11 changes: 2 additions & 9 deletions popup/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</head>
<body>
<div id="toggleHistory">
<button id="historyButton">Show History</button><br><br>
<a href="./history.html"><button>Show History</button></a>
<br><br>
</div>
<div id="noEME">
Widevine content hasn't detected in this page.<br>
Expand Down Expand Up @@ -70,20 +71,12 @@ <h3>Clearkey detected</h3>
<input type="text" id="requestSearch" placeholder="Search">
<ul id="requestList"></ul>
</div>
<div id="history" class="hidden">
<button id="backHistory">🔙 Back</button>
<button id="saveHistory">💾 Save History</button>
<button id="clearHistory">❌ Clear History</button>
<div id="histDisp"></div>
</div>
<div id="updateNotice" class="hidden">
Version =VER= update available!
<a href="https://github.com/FoxRefire/wvg/archive/=HASH=.zip">Download</a>
</div>
</body>
<script src="./main.js" type="module"></script>
<script src="./drawList.js"></script>
<script src="/libs/jsonview.js"></script>
<script src="./showHistory.js"></script>
<script src="./updateNotice.js"></script>
</html>

0 comments on commit ec92722

Please sign in to comment.