Fix extension popup in chrome

This commit is contained in:
Tamius Han 2020-12-06 21:57:16 +01:00
parent eb02865131
commit 7d8f3912bb
4 changed files with 38 additions and 5 deletions

View File

@ -5,13 +5,17 @@
</template>
<script>
import BrowserDetect from '../../ext/conf/BrowserDetect';
export default {
props: {
icon: String,
},
data() {
// note webextension-polyfill is not gonna save us here.
// been there, tried that.
return {
bootstrapIconsBasePath: (browser ?? chrome).runtime.getURL('/res/icons/bootstrap-icons.svg'),
bootstrapIconsBasePath: (BrowserDetect.firefox ? browser : chrome).runtime.getURL('/res/icons/bootstrap-icons.svg'),
iconHref: '',
};
},

View File

@ -213,6 +213,7 @@ export default {
try {
if (BrowserDetect.firefox) {
// reminder webextension-polyfill doesn't seem to work in vue!
await browser.permissions.request({permissions: ['downloads']});
browser.downloads.download({saveAs: true, filename: 'ultrawidify-settings.json', url: fileUrl});
} else if (BrowserDetect.chrome) {

View File

@ -1,6 +1,16 @@
<template>
<!--
NOTE the code that makes ultrawidify popup work in firefox regardless of whether the
extension is being displayed in a normal or a small/overflow popup breaks the popup
behaviour on Chrome (where the popup would never reach the full width of 800px)
Since I'm tired and the hour is getting late, we'll just add an extra CSS class for
non-firefox builds of this extension and be done with it. No need to complicate things
further than that.
-->
<div v-if="settingsInitialized"
class="popup flex flex-column no-overflow"
:class="{'popup-chrome': ! BrowserDetect.firefox}"
>
<div class="flex-row flex-nogrow flex-noshrink relative"
:class="{'header': !narrowPopup, 'header-small': narrowPopup}"
@ -289,7 +299,8 @@ export default {
AboutPanel,
Donate,
SiteDetailsPanel,
WhatsNewPanel, Icon
WhatsNewPanel,
Icon,
},
methods: {
async sleep(t) {
@ -660,11 +671,27 @@ html {
}
.popup {
// max-width: 780px;
// width: 800px;
height: 600px;
}
/**
This was written at the top, but it's worth repeating.
NOTE the code that makes ultrawidify popup work in firefox regardless of whether the
extension is being displayed in a normal or a small/overflow popup breaks the popup
behaviour on Chrome (where the popup would never reach the full width of 800px)
Since I'm tired and the hour is getting late, we'll just add an extra CSS class for
non-firefox builds of this extension and be done with it. No need to complicate things
further than that.
It also seems that Chrome doesn't like if we set the width of the popup all the way to
800px (probably something something scrollbar), so let's just take away a few px.
*/
.popup-chrome {
width: 780px !important;
}
.relative {
position: relative;
}

View File

@ -47,7 +47,8 @@ export default {
},
data() {
return {
addonVersion: browser.runtime.getManifest().version || chrome.runtime.getManifest().version,
// reminder webextension-polyfill doesn't seem to work in vue!
addonVersion: BrowserDetect.firefox ? browser.runtime.getManifest().version : chrome.runtime.getManifest().version,
loggingEnabled: false,
loggerSettings: '',
loggerSettingsError: false,