2018-12-30 23:16:09 +01:00
|
|
|
<template>
|
2020-12-06 21:57:16 +01:00
|
|
|
<!--
|
|
|
|
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.
|
|
|
|
-->
|
2021-07-05 00:49:35 +02:00
|
|
|
<div v-if="settingsInitialized"
|
2019-09-03 00:48:18 +02:00
|
|
|
class="popup flex flex-column no-overflow"
|
2022-09-20 01:34:59 +02:00
|
|
|
:class="{'popup-chrome': ! BrowserDetect?.firefox}"
|
2019-09-03 00:48:18 +02:00
|
|
|
>
|
2020-12-01 01:44:33 +01:00
|
|
|
<div class="flex-row flex-nogrow flex-noshrink relative"
|
|
|
|
:class="{'header': !narrowPopup, 'header-small': narrowPopup}"
|
|
|
|
>
|
2019-01-02 20:36:00 +01:00
|
|
|
<span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small>
|
2022-09-20 01:34:59 +02:00
|
|
|
<div class="absolute channel-info" v-if="BrowserDetect?.processEnvChannel !== 'stable'">
|
|
|
|
Build channel: {{BrowserDetect?.processEnvChannel}}
|
2020-05-16 20:31:56 +02:00
|
|
|
</div>
|
2019-01-02 20:36:00 +01:00
|
|
|
</div>
|
2022-11-20 22:45:34 +01:00
|
|
|
<div class="">
|
|
|
|
TODO: force open UI button
|
|
|
|
</div>
|
2019-07-02 01:23:43 +02:00
|
|
|
<div class="flex flex-row body no-overflow flex-grow">
|
2022-11-20 22:45:34 +01:00
|
|
|
<div class="">
|
|
|
|
side menu
|
|
|
|
</div>
|
2022-09-20 01:34:59 +02:00
|
|
|
<pre>
|
|
|
|
---- site:
|
|
|
|
{{site}}
|
|
|
|
|
|
|
|
----
|
|
|
|
</pre>
|
|
|
|
|
2019-01-02 20:36:00 +01:00
|
|
|
</div>
|
2018-12-30 23:16:09 +01:00
|
|
|
</div>
|
2022-07-26 23:54:25 +02:00
|
|
|
|
2018-12-30 23:16:09 +01:00
|
|
|
</template>
|
|
|
|
|
2021-03-11 21:58:12 +01:00
|
|
|
<script>
|
|
|
|
import Debug from '../ext/conf/Debug';
|
|
|
|
import BrowserDetect from '../ext/conf/BrowserDetect';
|
|
|
|
import Comms from '../ext/lib/comms/Comms';
|
2022-09-20 01:34:59 +02:00
|
|
|
import CommsClient from '../ext/lib/comms/CommsClient';
|
2021-03-11 21:58:12 +01:00
|
|
|
import Settings from '../ext/lib/Settings';
|
|
|
|
import Logger from '../ext/lib/Logger';
|
2022-09-20 01:34:59 +02:00
|
|
|
import EventBus from '../ext/lib/EventBus';
|
2021-03-11 21:58:12 +01:00
|
|
|
import {ChromeShittinessMitigations as CSM} from '../common/js/ChromeShittinessMitigations';
|
2021-03-29 21:15:01 +02:00
|
|
|
import { browser } from 'webextension-polyfill-ts';
|
2021-03-11 21:58:12 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data () {
|
2019-01-02 20:36:00 +01:00
|
|
|
return {
|
2022-09-20 01:34:59 +02:00
|
|
|
comms: undefined,
|
|
|
|
eventBus: new EventBus(),
|
2019-09-03 00:48:18 +02:00
|
|
|
settings: {},
|
|
|
|
settingsInitialized: false,
|
2020-12-01 01:44:33 +01:00
|
|
|
narrowPopup: null,
|
|
|
|
sideMenuVisible: null,
|
2022-07-26 23:54:25 +02:00
|
|
|
logger: undefined,
|
2022-09-20 01:34:59 +02:00
|
|
|
site: undefined,
|
2019-01-02 20:36:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async created() {
|
2020-01-28 01:26:40 +01:00
|
|
|
this.logger = new Logger();
|
|
|
|
await this.logger.init({
|
2020-01-16 01:00:12 +01:00
|
|
|
allowLogging: true,
|
2019-09-17 22:18:02 +02:00
|
|
|
});
|
2019-09-03 00:48:18 +02:00
|
|
|
|
2020-12-21 23:28:23 +01:00
|
|
|
this.settings = new Settings({afterSettingsSaved: () => this.updateConfig(), logger: this.logger});
|
2019-02-13 23:58:19 +01:00
|
|
|
await this.settings.init();
|
2019-09-03 00:48:18 +02:00
|
|
|
this.settingsInitialized = true;
|
|
|
|
|
2022-09-20 01:34:59 +02:00
|
|
|
// const port = browser.runtime.connect({name: 'popup-port'});
|
|
|
|
// port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
|
|
|
// CSM.setProperty('port', port);
|
|
|
|
|
|
|
|
this.eventBus = new EventBus();
|
|
|
|
this.eventBus.subscribe(
|
|
|
|
'set-current-site',
|
|
|
|
{
|
|
|
|
function: (config, context) => {
|
|
|
|
if (this.site) {
|
|
|
|
if (!this.site.host) {
|
|
|
|
// dunno why this fix is needed, but sometimes it is
|
|
|
|
this.site.host = config.site.host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.site = config.site;
|
|
|
|
this.selectedSite = this.selectedSite || config.site.host;
|
|
|
|
|
|
|
|
this.loadFrames(this.site);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.comms = new CommsClient('popup-port', this.logger, this.eventBus);
|
|
|
|
this.eventBus.setComms(this.comms);
|
2020-12-21 19:29:52 +01:00
|
|
|
|
2019-01-18 00:26:15 +01:00
|
|
|
|
|
|
|
// ensure we'll clean player markings on popup close
|
|
|
|
window.addEventListener("unload", () => {
|
2020-12-21 19:29:52 +01:00
|
|
|
CSM.port.postMessage({
|
2019-01-18 00:26:15 +01:00
|
|
|
cmd: 'unmark-player',
|
2019-04-13 03:09:29 +02:00
|
|
|
forwardToAll: true,
|
2019-01-18 00:26:15 +01:00
|
|
|
});
|
2021-03-11 21:58:12 +01:00
|
|
|
if (BrowserDetect.anyChromium) {
|
|
|
|
chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
|
|
|
cmd: 'unmark-player',
|
|
|
|
forwardToAll: true,
|
|
|
|
});
|
|
|
|
}
|
2019-01-18 00:26:15 +01:00
|
|
|
});
|
2019-04-13 03:09:29 +02:00
|
|
|
|
|
|
|
// get info about current site from background script
|
|
|
|
while (true) {
|
2022-09-20 01:38:08 +02:00
|
|
|
this.requestSite();
|
2019-04-13 03:09:29 +02:00
|
|
|
await this.sleep(5000);
|
2021-07-05 00:49:35 +02:00
|
|
|
}
|
2019-01-02 20:36:00 +01:00
|
|
|
},
|
2020-12-01 01:44:33 +01:00
|
|
|
async updated() {
|
|
|
|
const body = document.getElementsByTagName('body')[0];
|
|
|
|
|
|
|
|
// ensure that narrowPopup only gets set the first time the popup renders
|
|
|
|
// if popup was rendered before, we don't do anything because otherwise
|
|
|
|
// we'll be causing an unwanted re-render
|
2021-07-05 00:49:35 +02:00
|
|
|
//
|
2020-12-04 00:53:51 +01:00
|
|
|
// another thing worth noting — the popup gets first initialized with
|
|
|
|
// offsetWidth set to 0. This means proper popup will be displayed as a
|
|
|
|
// mini popup if we don't check for that.
|
|
|
|
if (this.narrowPopup === null && body.offsetWidth > 0) {
|
2020-12-01 01:44:33 +01:00
|
|
|
this.narrowPopup = body.offsetWidth < 600;
|
|
|
|
}
|
|
|
|
},
|
2019-01-02 20:36:00 +01:00
|
|
|
components: {
|
2019-02-16 01:19:29 +01:00
|
|
|
Debug,
|
2020-05-16 20:31:56 +02:00
|
|
|
BrowserDetect,
|
2019-01-03 02:07:16 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2019-01-18 00:26:15 +01:00
|
|
|
async sleep(t) {
|
2021-03-11 21:58:12 +01:00
|
|
|
return new Promise( (resolve,reject) => {
|
2019-01-18 00:26:15 +01:00
|
|
|
setTimeout(() => resolve(), t);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
toObject(obj) {
|
|
|
|
return JSON.parse(JSON.stringify(obj));
|
|
|
|
},
|
2022-09-20 01:34:59 +02:00
|
|
|
requestSite() {
|
2019-01-18 00:26:15 +01:00
|
|
|
try {
|
2019-09-03 00:48:18 +02:00
|
|
|
this.logger.log('info','popup', '[popup::getSite] Requesting current site ...')
|
2022-09-20 01:34:59 +02:00
|
|
|
// CSM.port.postMessage({command: 'get-current-site'});
|
|
|
|
this.eventBus.send(
|
|
|
|
'get-current-site',
|
|
|
|
undefined,
|
|
|
|
{
|
|
|
|
comms: {forwardTo: 'active'}
|
|
|
|
}
|
|
|
|
);
|
2019-01-18 00:26:15 +01:00
|
|
|
} catch (e) {
|
2019-09-03 00:48:18 +02:00
|
|
|
this.logger.log('error','popup','[popup::getSite] sending get-current-site failed for some reason. Reason:', e);
|
2019-01-18 00:26:15 +01:00
|
|
|
}
|
|
|
|
},
|
2021-03-11 21:58:12 +01:00
|
|
|
getRandomColor() {
|
|
|
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
|
|
|
},
|
2019-07-03 22:35:17 +02:00
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
processReceivedMessage(message, port) {
|
2019-09-03 00:48:18 +02:00
|
|
|
this.logger.log('info', 'popup', '[popup::processReceivedMessage] received message:', message)
|
2022-09-20 01:34:59 +02:00
|
|
|
console.info('[popup::processReceivedMessage] got message:', message);
|
2019-01-03 02:07:16 +01:00
|
|
|
|
2022-09-20 01:34:59 +02:00
|
|
|
if (message.command === 'set-current-site'){
|
2019-01-03 02:07:16 +01:00
|
|
|
if (this.site) {
|
2019-06-05 23:37:12 +02:00
|
|
|
if (!this.site.host) {
|
2019-01-03 02:07:16 +01:00
|
|
|
// dunno why this fix is needed, but sometimes it is
|
2021-03-11 21:58:12 +01:00
|
|
|
this.site.host = site.tabHostname;
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.site = message.site;
|
2019-06-07 01:50:13 +02:00
|
|
|
|
|
|
|
// update activeSites
|
|
|
|
// this.activeSites = this.activeSites.filter(x => x.host !== message.site);
|
|
|
|
|
|
|
|
// add current site
|
|
|
|
// this.activeSites = unshift({
|
|
|
|
// host: message.site.host,
|
|
|
|
// isIFrame: false, // currently unused
|
|
|
|
// });
|
2019-06-08 03:45:35 +02:00
|
|
|
this.selectedSite = this.selectedSite || message.site.host;
|
2019-06-07 01:50:13 +02:00
|
|
|
|
2019-01-18 00:26:15 +01:00
|
|
|
this.loadFrames(this.site);
|
|
|
|
}
|
2019-05-09 21:10:26 +02:00
|
|
|
|
2019-08-25 01:52:04 +02:00
|
|
|
return true;
|
2019-06-15 22:58:19 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
isDefaultFrame(frameId) {
|
|
|
|
return frameId === '__playing' || frameId === '__all';
|
2019-01-18 00:26:15 +01:00
|
|
|
},
|
2022-07-26 23:54:25 +02:00
|
|
|
loadFrames() {
|
2019-06-07 01:50:13 +02:00
|
|
|
this.activeSites = [{
|
|
|
|
host: this.site.host,
|
|
|
|
isIFrame: false, // not used tho. Maybe one day
|
|
|
|
}];
|
2019-06-08 03:45:35 +02:00
|
|
|
this.selectedSite = this.selectedSite || this.site.host;
|
2019-01-20 20:36:24 +01:00
|
|
|
|
2022-07-26 23:54:25 +02:00
|
|
|
// for (const frame in videoTab.frames) {
|
|
|
|
// this.activeFrames.push({
|
|
|
|
// id: `${this.site.id}-${frame}`,
|
|
|
|
// label: videoTab.frames[frame].host,
|
|
|
|
// ...this.frameStore[frame],
|
|
|
|
// })
|
|
|
|
|
|
|
|
// // only add each host once at most
|
|
|
|
// if (!this.activeSites.find(x => x.host === videoTab.frames[frame].host)) {
|
|
|
|
// this.activeSites.push({
|
|
|
|
// host: videoTab.frames[frame].host,
|
|
|
|
// isIFrame: undefined // maybe one day
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// }
|
2019-07-03 22:35:17 +02:00
|
|
|
|
|
|
|
// update whether video tab can be shown
|
|
|
|
this.updateCanShowVideoTab();
|
2019-01-03 02:07:16 +01:00
|
|
|
},
|
2021-03-11 21:58:12 +01:00
|
|
|
getRandomColor() {
|
2019-01-03 02:07:16 +01:00
|
|
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
|
|
|
}
|
2018-12-30 23:16:09 +01:00
|
|
|
}
|
2021-03-11 21:58:12 +01:00
|
|
|
}
|
2018-12-30 23:16:09 +01:00
|
|
|
</script>
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
<style src="../res/css/font/overpass.css"></style>
|
|
|
|
<style src="../res/css/font/overpass-mono.css"></style>
|
2020-03-01 20:24:08 +01:00
|
|
|
<style src="../res/css/flex.scss"></style>
|
2019-01-03 02:07:16 +01:00
|
|
|
<style src="../res/css/common.scss"></style>
|
|
|
|
|
2018-12-30 23:16:09 +01:00
|
|
|
<style lang="scss" scoped>
|
2020-12-01 01:44:33 +01:00
|
|
|
html {
|
|
|
|
// width: 800px !important;
|
|
|
|
// max-width: 800px !important;
|
2019-01-03 02:07:16 +01:00
|
|
|
padding: 0px;
|
|
|
|
margin: 0px;
|
|
|
|
}
|
|
|
|
|
2020-12-01 01:44:33 +01:00
|
|
|
.zero-width {
|
|
|
|
width: 0px !important;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header .header-small, .narrow-content {
|
|
|
|
padding: 8px;
|
|
|
|
}
|
|
|
|
|
2019-01-17 22:16:55 +01:00
|
|
|
#tablist {
|
|
|
|
min-width: 275px;
|
2020-03-15 20:19:48 +01:00
|
|
|
max-width: 300px;
|
2019-01-17 22:16:55 +01:00
|
|
|
}
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.header {
|
2019-01-17 22:16:55 +01:00
|
|
|
overflow: hidden;
|
2019-01-03 02:07:16 +01:00
|
|
|
background-color: #7f1416;
|
|
|
|
color: #fff;
|
|
|
|
margin: 0px;
|
|
|
|
margin-top: 0px;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-bottom: 1px;
|
2022-11-20 22:45:34 +01:00
|
|
|
font-size: 1.75rem;
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
2020-12-01 01:44:33 +01:00
|
|
|
.header-small {
|
|
|
|
overflow: hidden;
|
|
|
|
background-color: #7f1416;
|
|
|
|
color: #fff;
|
|
|
|
margin: 0px;
|
|
|
|
margin-top: 0px;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-bottom: 1px;
|
|
|
|
font-size: 1.27em;
|
|
|
|
}
|
2019-01-03 02:07:16 +01:00
|
|
|
|
2019-07-02 00:57:43 +02:00
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.menu-item-inline-desc{
|
|
|
|
font-size: 0.60em;
|
|
|
|
font-weight: 300;
|
|
|
|
font-variant: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-item {
|
2019-07-02 00:57:43 +02:00
|
|
|
flex-grow: 0;
|
2019-01-03 02:07:16 +01:00
|
|
|
padding-left: 15px;
|
|
|
|
padding-top: 5px;
|
|
|
|
padding-bottom: 5px;
|
|
|
|
font-variant: small-caps;
|
|
|
|
border-left: transparent 5px solid;
|
2019-07-02 00:57:43 +02:00
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-item-darker {
|
|
|
|
color: #999;
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.suboption {
|
|
|
|
display: block;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-right: 15px;
|
|
|
|
padding-top: 5px;
|
|
|
|
padding-bottom: 20px;
|
|
|
|
min-height: 250px;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#no-videos-display {
|
|
|
|
height: 100%;
|
|
|
|
padding-top: 50px;
|
|
|
|
/* text-align: center; */
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem-container {
|
|
|
|
padding-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected-tab {
|
|
|
|
background-color: initial;
|
|
|
|
border-left: #f18810 5px solid;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem {
|
|
|
|
font-variant: normal;
|
2019-01-20 21:12:26 +01:00
|
|
|
// font-size: 0.69em;
|
2019-07-02 01:23:43 +02:00
|
|
|
// margin-left: 16px;
|
2019-01-03 02:07:16 +01:00
|
|
|
border-left: transparent 3px solid;
|
|
|
|
padding-left: 12px;
|
|
|
|
margin-left: -10px;
|
|
|
|
}
|
|
|
|
|
2019-07-02 00:57:43 +02:00
|
|
|
.site-list {
|
|
|
|
max-height: 200px;
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.tabitem-selected {
|
|
|
|
color: #fff !important;
|
|
|
|
background-color: initial;
|
|
|
|
border-left: #f0c089 3px solid !important;
|
|
|
|
}
|
2020-12-04 00:26:39 +01:00
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.tabitem-selected::before {
|
2019-07-02 01:23:43 +02:00
|
|
|
padding-right: 8px;
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
|
|
|
|
2019-06-15 22:58:19 +02:00
|
|
|
.tabitem-disabled {
|
|
|
|
color: #cc3b0f !important;
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.tabitem-iframe::after {
|
|
|
|
content: "</>";
|
|
|
|
padding-left: 0.33em;
|
2018-12-30 23:16:09 +01:00
|
|
|
}
|
2019-01-17 22:16:55 +01:00
|
|
|
|
2020-12-04 00:26:39 +01:00
|
|
|
.menu-button {
|
|
|
|
margin-bottom: 4px;
|
|
|
|
padding: 4px;
|
|
|
|
border-bottom: #f18810 1px solid !important;
|
|
|
|
font-size: 1.5rem !important;
|
2020-12-04 00:53:51 +01:00
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;;
|
2020-12-04 00:26:39 +01:00
|
|
|
}
|
|
|
|
|
2019-01-17 22:16:55 +01:00
|
|
|
.popup {
|
|
|
|
height: 600px;
|
|
|
|
}
|
2020-05-16 20:31:56 +02:00
|
|
|
|
2020-12-06 21:57:16 +01:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
2021-07-05 00:49:35 +02:00
|
|
|
It also seems that Chrome doesn't like if we set the width of the popup all the way to
|
2020-12-06 21:57:16 +01:00
|
|
|
800px (probably something something scrollbar), so let's just take away a few px.
|
|
|
|
*/
|
|
|
|
.popup-chrome {
|
|
|
|
width: 780px !important;
|
|
|
|
}
|
|
|
|
|
2020-05-16 20:31:56 +02:00
|
|
|
.relative {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
.absolute {
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
.channel-info {
|
|
|
|
height: 0px;
|
|
|
|
right: 1.5rem;
|
|
|
|
bottom: 0.85rem;
|
|
|
|
font-size: 0.75rem;
|
|
|
|
}
|
2020-12-01 01:44:33 +01:00
|
|
|
|
|
|
|
.show-more {
|
|
|
|
padding-top: 12px;
|
|
|
|
font-size: 0.9rem;
|
|
|
|
}
|
2018-12-30 23:16:09 +01:00
|
|
|
</style>
|