This commit is contained in:
ccppi 2024-03-19 10:35:36 +01:00
parent bb5b01e027
commit a8989ee13a
3 changed files with 15 additions and 7 deletions

View File

@ -14,15 +14,13 @@ data = readUrl()
}); });
function handleMessages(message,sender,sendResponse,tab,data){ function handleMessages(message,sender,sendResponse,tab,data){
if(message === "Button_clicked") if(message.state === "Button_clicked")
{ {
browser.tabs.executeScript(tab.id,{ browser.tabs.executeScript(tab.id,{
file:"spawn.js" file:"spawn.js"
}); });
console.log("pass tab data to run, in promise");
console.log(tab); console.log(tab);
console.log(data); console.log(data);
//nextUrl(data,tab,i);
} }
else if(message === "Content_Loaded") else if(message === "Content_Loaded")
{ {

View File

@ -1,5 +1,8 @@
<html> <html>
<body> <body>
<div id="picker_zone" style="margin:20px ;color:blue">
<input type="file" accept="*.json" id="input">
</div>
test test
<button type="submit" id="id_run" value="run importer" name="b_submit">RUNRUNRUN</button> <button type="submit" id="id_run" value="run importer" name="b_submit">RUNRUNRUN</button>
<script type="text/javascript" language="javascript" src="home.js"></script> <script type="text/javascript" language="javascript" src="home.js"></script>

13
home.js
View File

@ -1,12 +1,19 @@
const fileField = document.querySelector('input[type="file"]');
fileField.addEventListener("change",() =>
{
console.log(fileField.files[0]);
});
document.getElementById("id_run").addEventListener("click", function(e){ document.getElementById("id_run").addEventListener("click", function(e){
console.log("triggered!!"); alert("Run script");
alert("judihudi");
startBackgroundScript(); startBackgroundScript();
e.preventDefault(); e.preventDefault();
}); });
function startBackgroundScript() function startBackgroundScript()
{ {
browser.runtime.sendMessage("Button_clicked"); browser.runtime.sendMessage({state : "Button_clicked",
fileHandler:fileField);
console.log("home.js sent button_clicked message..."); console.log("home.js sent button_clicked message...");
} }