From 60e5e46a0f711a44e8092b74b7bbcaaf9fbcaed0 Mon Sep 17 00:00:00 2001 From: FoxRefire <155989196+FoxRefire@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:50:53 +0900 Subject: [PATCH] Auto-detect licenseURL and scheme --- popup.js | 24 +++++++++++++++++++++--- selectRules.conf | 5 +++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 selectRules.conf diff --git a/popup.js b/popup.js index 1d04baa..70f0229 100644 --- a/popup.js +++ b/popup.js @@ -43,6 +43,26 @@ window.corsFetch = (u, m, h, b) => { }) } +async function autoSelect(){ + let selectRules = await fetch("selectRules.conf").then((r)=>r.text()); + selectRules = selectRules.replace(/\n^$/gm, ""); + selectRules=selectRules.split("\n").map(function(row){return row.split("$$");}); + for(var item of selectRules){ + let search = requests.map(r => r['url']).findIndex(e => e.includes(item[0])); + if(search>=0){ + if(item[1]) document.getElementById("scheme").value = item[1]; + requestList.children[search].click(); + break; + } + } + if(psshs.length==1){ + document.getElementById('pssh').value=psshs[0]; + } + if(requests.length==1){ + requestList.children[0].click(); + } +} + if(psshs.length!=0){ document.addEventListener('DOMContentLoaded', function() { document.getElementById('noEME').style.display='none'; @@ -51,8 +71,6 @@ if(psshs.length!=0){ document.getElementById('result').addEventListener("click", copyResult); drawList(psshs,'psshSearch','psshList','pssh'); drawList(requests.map(r => r['url']),'requestSearch','requestList','license'); - if(psshs.length==1){ - document.getElementById('pssh').value=psshs[0]; - } + autoSelect(); }); } diff --git a/selectRules.conf b/selectRules.conf new file mode 100644 index 0000000..1638717 --- /dev/null +++ b/selectRules.conf @@ -0,0 +1,5 @@ +cwip-shaka-proxy +c4.eme.lp.aws.redbee$$RedBee +lic.staging.drmtoday$$DRMToday +license-ap +licenseManager.do