diff --git a/background.js b/background.js index bb49282..3ad811e 100644 --- a/background.js +++ b/background.js @@ -2,6 +2,7 @@ window.psshs=[]; window.requests=[]; window.bodys=[]; +window.targetIds=[]; window.pageURL=""; window.clearkey=""; @@ -63,11 +64,10 @@ chrome.runtime.onMessage.addListener( case "RESET": location.reload() break; - case "URL": - window.pageURL=request.text - break; case "PSSH": window.psshs.push(request.text) + window.pageURL=sender.tab.url + window.targetIds=[sender.tab.id, sender.frameId] break; case "CLEARKEY": window.clearkey=request.text diff --git a/content.js b/content.js index 11e4fe9..6e26647 100644 --- a/content.js +++ b/content.js @@ -8,12 +8,6 @@ script.src = chrome.runtime.getURL("inject.js"); //Reset variables at every page load in background.js if (window === window.parent){ chrome.runtime.sendMessage({type: "RESET"},null); - setTimeout( ()=>{ - chrome.runtime.sendMessage({ - type: "URL", - text: document.URL - },null); - }, 700); } //Send PSSH into background.js diff --git a/popup.js b/popup.js index abf30d9..a80ddbb 100644 --- a/popup.js +++ b/popup.js @@ -1,6 +1,7 @@ let psshs=chrome.extension.getBackgroundPage().psshs; let requests=chrome.extension.getBackgroundPage().requests; let pageURL=chrome.extension.getBackgroundPage().pageURL; +let targetIds=chrome.extension.getBackgroundPage().targetIds; let clearkey=chrome.extension.getBackgroundPage().clearkey; async function guess(){ @@ -30,7 +31,7 @@ async function guess(){ PSSH: document.getElementById('pssh').value, KEYS: result.split("\n").slice(0,-1) } - chrome.storage.local.set({[pageURL]: historyData}, function () {}); + chrome.storage.local.set({[pageURL]: historyData}, null); //All Done! document.body.style.cursor = "auto"; @@ -44,10 +45,8 @@ function copyResult(){ window.corsFetch = (u, m, h, b) => { return new Promise((resolve, reject) => { - chrome.tabs.query({ url:pageURL }, (tabs) => { - chrome.tabs.sendMessage(tabs[0].id, {type:"FETCH", u:u, m:m, h:h, b:b}, (res) => { - resolve(res) - }) + chrome.tabs.sendMessage(targetIds[0], {type:"FETCH", u:u, m:m, h:h, b:b}, {frameId:targetIds[1]}, res => { + resolve(res) }) }) }