Ensure tabID is unchanged; fix image styles

This commit is contained in:
Will Bamberg
2017-09-11 21:59:52 -07:00
parent a37ea20e24
commit 7d2ba28b0b
2 changed files with 14 additions and 15 deletions
+1 -2
View File
@@ -35,8 +35,7 @@
function insertBeast(beastURL) { function insertBeast(beastURL) {
var beastImage = document.createElement("img"); var beastImage = document.createElement("img");
beastImage.setAttribute("src", beastURL); beastImage.setAttribute("src", beastURL);
beastImage.setAttribute("style", "width: 100vw"); beastImage.style.height = "100vh";
beastImage.setAttribute("style", "height: 100vh");
document.body.appendChild(beastImage); document.body.appendChild(beastImage);
} }
+13 -13
View File
@@ -27,23 +27,23 @@ If it's on a button which contains class "clear":
*/ */
document.addEventListener("click", (e) => { document.addEventListener("click", (e) => {
function messageBeastify() { function reportError(error) {
var chosenBeast = e.target.textContent; console.error(`Could not beastify: ${error}`);
var chosenBeastURL = beastNameToURL(chosenBeast); }
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
gettingActiveTab.then((tabs) => { function beastify(tabs) {
browser.tabs.sendMessage(tabs[0].id, {beastURL: chosenBeastURL}); browser.tabs.executeScript(tabs[0].id, {
file: "/content_scripts/beastify.js"
}).then(() => {
var chosenBeast = e.target.textContent;
var url = beastNameToURL(chosenBeast);
browser.tabs.sendMessage(tabs[0].id, {beastURL: url});
}); });
} }
function reportError(error) {
console.error(`Could not inject content script: ${error}`);
}
if (e.target.classList.contains("beast")) { if (e.target.classList.contains("beast")) {
browser.tabs.executeScript({ browser.tabs.query({active: true, currentWindow: true})
file: "/content_scripts/beastify.js" .then(beastify)
}).then(messageBeastify)
.catch(reportError); .catch(reportError);
} }
else if (e.target.classList.contains("clear")) { else if (e.target.classList.contains("clear")) {