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

View File

@@ -35,8 +35,7 @@
function insertBeast(beastURL) {
var beastImage = document.createElement("img");
beastImage.setAttribute("src", beastURL);
beastImage.setAttribute("style", "width: 100vw");
beastImage.setAttribute("style", "height: 100vh");
beastImage.style.height = "100vh";
document.body.appendChild(beastImage);
}

View File

@@ -27,23 +27,23 @@ If it's on a button which contains class "clear":
*/
document.addEventListener("click", (e) => {
function messageBeastify() {
var chosenBeast = e.target.textContent;
var chosenBeastURL = beastNameToURL(chosenBeast);
var gettingActiveTab = browser.tabs.query({active: true, currentWindow: true});
gettingActiveTab.then((tabs) => {
browser.tabs.sendMessage(tabs[0].id, {beastURL: chosenBeastURL});
function reportError(error) {
console.error(`Could not beastify: ${error}`);
}
function beastify(tabs) {
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")) {
browser.tabs.executeScript({
file: "/content_scripts/beastify.js"
}).then(messageBeastify)
browser.tabs.query({active: true, currentWindow: true})
.then(beastify)
.catch(reportError);
}
else if (e.target.classList.contains("clear")) {