Make more firefox dependant, but better ish
This commit is contained in:
parent
ef604302a4
commit
940935e18e
|
@ -16,15 +16,11 @@
|
|||
setTimeout(checkIfReady, 200);
|
||||
}
|
||||
|
||||
const expressionExport = document.createElement("div");
|
||||
expressionExport.id = "EXPORTEXPRESSION";
|
||||
expressionExport.style.display = "none";
|
||||
const expressionImport = document.createElement("div");
|
||||
expressionImport.id = "IMPORTEXPRESSION";
|
||||
expressionImport.style.display = "none";
|
||||
|
||||
document.body.appendChild(expressionImport);
|
||||
document.body.appendChild(expressionExport);
|
||||
|
||||
function download(filename, textInput) {
|
||||
var element = document.createElement('a');
|
||||
|
@ -82,24 +78,18 @@
|
|||
function loadExpr(json) {
|
||||
const expressions = JSON.stringify(json);
|
||||
var scriptTag = document.createElement('script');
|
||||
scriptTag.src = chrome.extension.getURL('inject_scripts/load.js');
|
||||
scriptTag.src = browser.runtime.getURL('inject_scripts/load.js');
|
||||
scriptTag.onload = function () { this.parentNode.removeChild(this); };
|
||||
document.getElementById("IMPORTEXPRESSION").textContent = expressions;
|
||||
document.body.append(scriptTag);
|
||||
}
|
||||
|
||||
function saveExpr() {
|
||||
var scriptTag = document.createElement('script');
|
||||
const expressions = window.wrappedJSObject.Calc.getExpressions();
|
||||
const graphTitle = document.querySelector(".align-left-container").querySelector(".dcg-variable-title").textContent + ".json";
|
||||
scriptTag.src = chrome.extension.getURL('inject_scripts/save.js');
|
||||
scriptTag.onload = function () { this.parentNode.removeChild(this); };
|
||||
document.body.append(scriptTag);
|
||||
|
||||
document.addEventListener("updatedExpression", () => {
|
||||
const expressionsString = document.getElementById("EXPORTEXPRESSION").textContent;
|
||||
const expressionsString = JSON.stringify(expressions);
|
||||
download(graphTitle, expressionsString);
|
||||
document.getElementById("EXPORTEXPRESSION").textContent = "";
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
(function () {
|
||||
const expressions = Calc.getExpressions();
|
||||
const expressionBox = document.getElementById("EXPORTEXPRESSION");
|
||||
expressionBox.textContent = JSON.stringify(expressions);
|
||||
const updateEvent = new Event("updatedExpression");
|
||||
document.dispatchEvent(updateEvent);
|
||||
})();
|
|
@ -17,11 +17,9 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"host_permissions": [
|
||||
"https://www.desmos.com/"
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
"inject_scripts/*.js"
|
||||
"inject_scripts/load.js",
|
||||
"inject_scripts/save.js"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": "icons/icon-32.png",
|
||||
|
|
Loading…
Reference in a new issue