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