Compare commits

..

No commits in common. "d34c975eaa5b45fd81cf3991c39c391200a8ce35" and "a5fdef01968a0808db7e080f622cc2edf4406092" have entirely different histories.

32 changed files with 80 additions and 224 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "ultrawidify", "name": "ultrawidify",
"version": "6.3.9", "version": "6.3.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "ultrawidify", "name": "ultrawidify",
"version": "6.3.9", "version": "6.3.0",
"description": "Aspect ratio fixer for youtube and other sites, with automatic aspect ratio detection. Supports ultrawide and other ratios.", "description": "Aspect ratio fixer for youtube and other sites, with automatic aspect ratio detection. Supports ultrawide and other ratios.",
"author": "Tamius Han <tamius.han@gmail.com>", "author": "Tamius Han <tamius.han@gmail.com>",
"scripts": { "scripts": {

View File

@ -308,9 +308,6 @@ export interface SiteSettingsInterface {
enableKeyboard: ExtensionEnvironmentSettingsInterface; enableKeyboard: ExtensionEnvironmentSettingsInterface;
enableUI: ExtensionEnvironmentSettingsInterface; // Lies! enableUI doesn't use 'theater' property (but uses the other two) enableUI: ExtensionEnvironmentSettingsInterface; // Lies! enableUI doesn't use 'theater' property (but uses the other two)
applyToEmbeddedContent?: boolean; // presumed to be 'true' if not defined
autocreated?: boolean; autocreated?: boolean;
type?: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified'; type?: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified';
defaultType: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified'; defaultType: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified';

View File

@ -205,7 +205,7 @@ import GhettoContextMenuItem from '@csui/src/components/GhettoContextMenuItem.vu
import GhettoContextMenuOption from '@csui/src/components/GhettoContextMenuOption.vue'; import GhettoContextMenuOption from '@csui/src/components/GhettoContextMenuOption.vue';
import AlignmentOptionsControlComponent from '@csui/src/PlayerUiPanels/AlignmentOptionsControlComponent.vue'; import AlignmentOptionsControlComponent from '@csui/src/PlayerUiPanels/AlignmentOptionsControlComponent.vue';
import BrowserDetect from '@src/ext/conf/BrowserDetect'; import BrowserDetect from '@src/ext/conf/BrowserDetect';
import Settings from '@src/ext/lib/settings/Settings'; import Settings from '@src/ext/lib/Settings';
import EventBus from '@src/ext/lib/EventBus'; import EventBus from '@src/ext/lib/EventBus';
import UIProbeMixin from '@csui/src/utils/UIProbeMixin'; import UIProbeMixin from '@csui/src/utils/UIProbeMixin';
import KeyboardShortcutParserMixin from '@csui/src/utils/KeyboardShortcutParserMixin'; import KeyboardShortcutParserMixin from '@csui/src/utils/KeyboardShortcutParserMixin';
@ -463,7 +463,7 @@ export default {
if (!this.site) { if (!this.site) {
this.origin = event.origin; this.origin = event.origin;
this.site = event.origin.split('//')[1]; this.site = event.origin.split('//')[1];
this.siteSettings = this.settings.getSiteSettings({site: this.site}); this.siteSettings = this.settings.getSiteSettings(this.site);
} }
return this.handleProbe(event.data, event.origin); // handleProbe is defined in UIProbeMixin return this.handleProbe(event.data, event.origin); // handleProbe is defined in UIProbeMixin
case 'uw-bus-tunnel': case 'uw-bus-tunnel':

View File

@ -123,7 +123,7 @@ import AboutPanel from '@csui/src/popup/panels/AboutPanel.vue'
import Debug from '../ext/conf/Debug'; import Debug from '../ext/conf/Debug';
import BrowserDetect from '../ext/conf/BrowserDetect'; import BrowserDetect from '../ext/conf/BrowserDetect';
import CommsClient, {CommsOrigin} from '../ext/lib/comms/CommsClient'; import CommsClient, {CommsOrigin} from '../ext/lib/comms/CommsClient';
import Settings from '../ext/lib/settings/Settings'; import Settings from '../ext/lib/Settings';
import EventBus from '../ext/lib/EventBus'; import EventBus from '../ext/lib/EventBus';
import {ChromeShittinessMitigations as CSM} from '../common/js/ChromeShittinessMitigations'; import {ChromeShittinessMitigations as CSM} from '../common/js/ChromeShittinessMitigations';
import SupportLevelIndicator from '@csui/src/components/SupportLevelIndicator.vue' import SupportLevelIndicator from '@csui/src/components/SupportLevelIndicator.vue'
@ -193,6 +193,8 @@ export default {
{ {
source: this, source: this,
function: (config, context) => { function: (config, context) => {
console.log('set-current-site | this.site:', this.site, 'config.site:', config.site);
if (this.site) { if (this.site) {
if (!this.site.host) { if (!this.site.host) {
// dunno why this fix is needed, but sometimes it is // dunno why this fix is needed, but sometimes it is
@ -201,7 +203,7 @@ export default {
} }
this.site = config.site; this.site = config.site;
// this.selectedSite = this.selectedSite || config.site.host; // this.selectedSite = this.selectedSite || config.site.host;
this.siteSettings = this.settings.getSiteSettings({site: this.site.host}); this.siteSettings = this.settings.getSiteSettings(this.site.host);
this.eventBus.setupPopupTunnelWorkaround({ this.eventBus.setupPopupTunnelWorkaround({
origin: CommsOrigin.Popup, origin: CommsOrigin.Popup,
comms: { comms: {

View File

@ -376,9 +376,6 @@ button,
padding-left: 35px; padding-left: 35px;
float: right; float: right;
} }
.info-color {
color: $info-color;
}
.info::before { .info::before {
content: ""; content: "";

View File

@ -205,7 +205,7 @@ export default {
if (this.defaultTab) { if (this.defaultTab) {
this.selectedTab = this.defaultTab; this.selectedTab = this.defaultTab;
} }
this.siteSettings = this.settings.getSiteSettings({site: this.site}); this.siteSettings = this.settings.getSiteSettings(this.site);
this.tabs.find(x => x.id === 'changelog').highlight = !this.settings.active?.whatsNewChecked; this.tabs.find(x => x.id === 'changelog').highlight = !this.settings.active?.whatsNewChecked;
this.eventBus.subscribe( this.eventBus.subscribe(

View File

@ -41,7 +41,6 @@
<template v-if="hosts && tab === 'embeddedSites' && globalSettings"> <template v-if="hosts && tab === 'embeddedSites' && globalSettings">
<FrameSiteSettings <FrameSiteSettings
v-if="settings" v-if="settings"
:parentHost="site"
:hosts="hosts" :hosts="hosts"
:settings="settings" :settings="settings"
></FrameSiteSettings> ></FrameSiteSettings>
@ -197,7 +196,7 @@ export default {
}, },
siteSettings() { siteSettings() {
if (this.site) { if (this.site) {
return this.settings?.getSiteSettings({site: this.site}) ?? null; return this.settings?.getSiteSettings(this.site) ?? null;
} }
return null; return null;
}, },

View File

@ -15,7 +15,6 @@
<li>Subdomains now inherit same settings as their parent domain by default</li> <li>Subdomains now inherit same settings as their parent domain by default</li>
<li>Extension attempts to detect embedded content.</li> <li>Extension attempts to detect embedded content.</li>
</ul> </ul>
</div> </div>
<div style="width: 1rem; height: 0px;"></div> <div style="width: 1rem; height: 0px;"></div>
<div class="min-w-[400px] max-w-[520px] grow shrink"> <div class="min-w-[400px] max-w-[520px] grow shrink">

View File

@ -11,7 +11,6 @@
</div> </div>
<div v-for="host of hosts" :key="host" @click="selectedSite = host" class="flex flex-col container pointer hoverable" style="margin-top: 4px; padding: 0.5rem 1rem;"> <div v-for="host of hosts" :key="host" @click="selectedSite = host" class="flex flex-col container pointer hoverable" style="margin-top: 4px; padding: 0.5rem 1rem;">
<SiteListItem <SiteListItem
:parentHost="parentHost"
:host="host" :host="host"
:settings="settings" :settings="settings"
></SiteListItem> ></SiteListItem>
@ -49,7 +48,6 @@ export default {
}, },
props: [ props: [
'settings', 'settings',
'parentHost',
'hosts', 'hosts',
], ],
data() { data() {
@ -83,7 +81,7 @@ export default {
} }
}, },
selectedSiteSettings() { selectedSiteSettings() {
return this.settings?.getSiteSettings({site: this.selectedSite}) ?? null; return this.settings?.getSiteSettings(this.selectedSite) ?? null;
} }
}, },
methods: { methods: {

View File

@ -121,7 +121,7 @@ export default {
} }
}, },
selectedSiteSettings() { selectedSiteSettings() {
return this.settings?.getSiteSettings({site: this.selectedSite}) ?? null; return this.settings?.getSiteSettings(this.selectedSite) ?? null;
} }
}, },
methods: { methods: {
@ -140,13 +140,13 @@ export default {
return status === 'disabled' ? 'color: #f00' : 'color: #1f8'; return status === 'disabled' ? 'color: #f00' : 'color: #1f8';
}, },
getSiteEnabledModes(site, component) { getSiteEnabledModes(site, component) {
if (this.settings?.getSiteSettings({site: site}).data[component]?.normal === ExtensionMode.Enabled) { if (this.settings?.getSiteSettings(site).data[component]?.normal === ExtensionMode.Enabled) {
return 'always'; return 'always';
} }
if (this.settings?.getSiteSettings({site: site}).data[component]?.theater === ExtensionMode.Enabled) { if (this.settings?.getSiteSettings(site).data[component]?.theater === ExtensionMode.Enabled) {
return 'T + FS'; return 'T + FS';
} }
if (this.settings?.getSiteSettings({site: site}).data[component]?.fullscreen === ExtensionMode.Enabled) { if (this.settings?.getSiteSettings(site).data[component]?.fullscreen === ExtensionMode.Enabled) {
return 'fullscreen'; return 'fullscreen';
} }
return 'disabled'; return 'disabled';

View File

@ -11,7 +11,7 @@
</div> </div>
<div v-if="this.siteSettings?.usesSettingsFor"> <div v-if="this.siteSettings?.usesSettingsFor">
<div v-if="this.siteSettings.usesSettingsFor === '@global'">Uses default settings</div> <div v-if="this.siteSettings.usesSettingsFor === '@global'">Uses default settings</div>
<div v-else>Uses settings for: <span class="info-color">{{this.siteSettings.usesSettingsFor}}</span></div> <div v-else>Uses settings for: {{this.siteSettings.usesSettingsFor}}</div>
</div> </div>
<div class="flex flex-row"> <div class="flex flex-row">
<small> <small>
@ -35,11 +35,10 @@ export default {
}, },
props: [ props: [
'settings', 'settings',
'parentHost',
'host', 'host',
], ],
created() { created() {
this.siteSettings = this.settings.getSiteSettings({site: this.host, isIframe: this.parentHost && this.host !== this.parentHost, parentHostname: this.parentHost}); this.siteSettings = this.settings.getSiteSettings(this.host);
}, },
methods: { methods: {
getSiteTypeColor(siteType) { getSiteTypeColor(siteType) {

View File

@ -175,7 +175,7 @@ export default {
this.enabledHosts = []; this.enabledHosts = [];
for (const host of val) { for (const host of val) {
const siteSettings = new SiteSettings(this.settings, {site: host}); const siteSettings = new SiteSettings(this.settings, host);
if (siteSettings.isEnabledForEnvironment(false, true) === ExtensionMode.Enabled) { if (siteSettings.isEnabledForEnvironment(false, true) === ExtensionMode.Enabled) {
this.enabledHosts.push(host); this.enabledHosts.push(host);

View File

@ -1,5 +1,5 @@
import Debug from './conf/Debug'; import Debug from './conf/Debug';
import Settings from './lib/settings/Settings'; import Settings from './lib/Settings';
import CommsClient from './lib/comms/CommsClient'; import CommsClient from './lib/comms/CommsClient';
import PageInfo from './lib/video-data/PageInfo'; import PageInfo from './lib/video-data/PageInfo';
import EventBus from './lib/EventBus'; import EventBus from './lib/EventBus';
@ -8,7 +8,6 @@ import { SiteSettings } from './lib/settings/SiteSettings';
import UI from './lib/uwui/UI'; import UI from './lib/uwui/UI';
import { BLANK_LOGGER_CONFIG, LogAggregator } from './lib/logging/LogAggregator'; import { BLANK_LOGGER_CONFIG, LogAggregator } from './lib/logging/LogAggregator';
import { ComponentLogger } from './lib/logging/ComponentLogger'; import { ComponentLogger } from './lib/logging/ComponentLogger';
import { getIframeParentHost, setupHostnameReporting } from './util/getHost';
export default class UWContent { export default class UWContent {
pageInfo: PageInfo; pageInfo: PageInfo;
@ -20,7 +19,6 @@ export default class UWContent {
logger: ComponentLogger; logger: ComponentLogger;
eventBus: EventBus; eventBus: EventBus;
isIframe: boolean = false; isIframe: boolean = false;
parentHostname: string;
globalUi: any; globalUi: any;
@ -30,8 +28,7 @@ export default class UWContent {
} }
constructor(){ constructor(){
setupHostnameReporting(); this.isIframe = window.self !== window.top
this.isIframe = window.self !== window.top;
} }
reloadSettings() { reloadSettings() {
@ -44,11 +41,6 @@ export default class UWContent {
} }
async init(){ async init(){
if (this.isIframe) {
this.parentHostname = await getIframeParentHost();
console.warn('[uw-content] got iframe parent:', this.parentHostname);
}
try { try {
if (Debug.debug) { if (Debug.debug) {
console.log("[uw::main] loading configuration ..."); console.log("[uw::main] loading configuration ...");
@ -65,7 +57,6 @@ export default class UWContent {
console.error("logger init failed!", e) console.error("logger init failed!", e)
} }
// init() is re-run any time settings change // init() is re-run any time settings change
if (this.comms) { if (this.comms) {
this.comms.destroy(); this.comms.destroy();
@ -79,7 +70,7 @@ export default class UWContent {
logAggregator: this.logAggregator logAggregator: this.logAggregator
}); });
await this.settings.init(); await this.settings.init();
this.siteSettings = this.settings.getSiteSettings({site: window.location.hostname, isIframe: this.isIframe, parentHostname: this.parentHostname}); this.siteSettings = this.settings.getSiteSettings();
} }
this.eventBus = new EventBus(); this.eventBus = new EventBus();

View File

@ -1,7 +1,7 @@
import Debug from './conf/Debug.js'; import Debug from './conf/Debug.js';
import BrowserDetect from './conf/BrowserDetect'; import BrowserDetect from './conf/BrowserDetect';
import CommsServer from './lib/comms/CommsServer'; import CommsServer from './lib/comms/CommsServer';
import Settings from './lib/settings/Settings'; import Settings from './lib/Settings';
import { sleep } from '../common/js/utils'; import { sleep } from '../common/js/utils';
import EventBus, { EventBusCommand } from './lib/EventBus'; import EventBus, { EventBusCommand } from './lib/EventBus';
import { ComponentLogger } from './lib/logging/ComponentLogger'; import { ComponentLogger } from './lib/logging/ComponentLogger';

View File

@ -1,14 +1,14 @@
import Debug from '../../conf/Debug'; import Debug from '../conf/Debug';
import ExtensionConf from '../../conf/ExtensionConf'; import ExtensionConf from '../conf/ExtensionConf';
import ObjectCopy from '../ObjectCopy'; import ObjectCopy from './ObjectCopy';
import StretchType from '../../../common/enums/StretchType.enum'; import StretchType from '../../common/enums/StretchType.enum';
import ExtensionConfPatch from '../../conf/ExtConfPatches'; import ExtensionConfPatch from '../conf/ExtConfPatches';
import SettingsInterface from '../../../common/interfaces/SettingsInterface'; import SettingsInterface from '../../common/interfaces/SettingsInterface';
import AspectRatioType from '../../../common/enums/AspectRatioType.enum'; import AspectRatioType from '../../common/enums/AspectRatioType.enum';
import { GetSiteSettingsOptions, SiteSettings } from './SiteSettings'; import { SiteSettings } from './settings/SiteSettings';
import { SettingsSnapshotManager } from './SettingsSnapshotManager'; import { SettingsSnapshotManager } from './settings/SettingsSnapshotManager';
import { ComponentLogger } from '../logging/ComponentLogger'; import { ComponentLogger } from './logging/ComponentLogger';
import { LogAggregator } from '../logging/LogAggregator'; import { LogAggregator } from './logging/LogAggregator';
if(process.env.CHANNEL !== 'stable'){ if(process.env.CHANNEL !== 'stable'){
console.info("Loading Settings"); console.info("Loading Settings");
@ -25,7 +25,6 @@ interface SetSettingsOptions {
forcePreserveVersion?: boolean, forcePreserveVersion?: boolean,
} }
const SETTINGS_LOGGER_STYLES = { const SETTINGS_LOGGER_STYLES = {
log: 'color: #81d288', log: 'color: #81d288',
} }
@ -414,8 +413,8 @@ class Settings {
} }
} }
getSiteSettings(options: GetSiteSettingsOptions = {site: window.location.hostname}): SiteSettings { getSiteSettings(site: string = window.location.hostname): SiteSettings {
return new SiteSettings(this, options); return new SiteSettings(this, site);
} }
listenOnChange(fn: () => void): void { listenOnChange(fn: () => void): void {

View File

@ -3,7 +3,7 @@ import ExtensionMode from '@src/common/enums/ExtensionMode.enum';
import { ArVariant } from '@src/common/interfaces/ArInterface'; import { ArVariant } from '@src/common/interfaces/ArInterface';
import { ExtensionEnvironment } from '@src/common/interfaces/SettingsInterface'; import { ExtensionEnvironment } from '@src/common/interfaces/SettingsInterface';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';
import VideoData from '../video-data/VideoData'; import VideoData from '../video-data/VideoData';
import { AardDebugUi } from './AardDebugUi'; import { AardDebugUi } from './AardDebugUi';
@ -2049,7 +2049,7 @@ export class Aard {
* Calculates video's current aspect ratio based on data in testResults. * Calculates video's current aspect ratio based on data in testResults.
* @returns * @returns
*/ */
private getAr(): number { private getAr() {
const fileAr = this.video.videoWidth / this.video.videoHeight; const fileAr = this.video.videoWidth / this.video.videoHeight;
const canvasAr = this.canvasStore.main.width / this.canvasStore.main.height; const canvasAr = this.canvasStore.main.width / this.canvasStore.main.height;

View File

@ -1,5 +1,5 @@
import { ComponentLogger } from './../logging/ComponentLogger'; import { ComponentLogger } from './../logging/ComponentLogger';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
import { CommsOrigin } from './CommsClient'; import { CommsOrigin } from './CommsClient';
@ -148,6 +148,7 @@ class CommsServer {
} }
} }
console.log('uniq hosts:', hosts)
return hosts; return hosts;
} }

View File

@ -1,6 +1,6 @@
import EventBus, { EventBusCommand } from '../EventBus'; import EventBus, { EventBusCommand } from '../EventBus';
import { ComponentLogger } from '../logging/ComponentLogger'; import { ComponentLogger } from '../logging/ComponentLogger';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';
export class KbmBase { export class KbmBase {

View File

@ -1,5 +1,5 @@
import ExtensionMode from '../../../common/enums/ExtensionMode.enum'; import ExtensionMode from '../../../common/enums/ExtensionMode.enum';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import EventBus, { EventBusCommand } from '../EventBus'; import EventBus, { EventBusCommand } from '../EventBus';
import KbmBase from './KbmBase'; import KbmBase from './KbmBase';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';

View File

@ -1,7 +1,7 @@
import { LogAggregator } from './../logging/LogAggregator'; import { LogAggregator } from './../logging/LogAggregator';
import EventBus, { EventBusCommand } from '../EventBus'; import EventBus, { EventBusCommand } from '../EventBus';
import { ComponentLogger } from '../logging/ComponentLogger'; import { ComponentLogger } from '../logging/ComponentLogger';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';
import KbmBase from './KbmBase'; import KbmBase from './KbmBase';

View File

@ -2,17 +2,10 @@ import CropModePersistence from '../../../common/enums/CropModePersistence.enum'
import ExtensionMode from '../../../common/enums/ExtensionMode.enum'; import ExtensionMode from '../../../common/enums/ExtensionMode.enum';
import { SettingsReloadComponent, SettingsReloadFlags, SiteSettingsInterface } from '../../../common/interfaces/SettingsInterface'; import { SettingsReloadComponent, SettingsReloadFlags, SiteSettingsInterface } from '../../../common/interfaces/SettingsInterface';
import { _cp } from '../../../common/js/utils'; import { _cp } from '../../../common/js/utils';
import Settings from './Settings'; import Settings from '../Settings';
import StretchType from '../../../common/enums/StretchType.enum'; import StretchType from '../../../common/enums/StretchType.enum';
import VideoAlignmentType from '../../../common/enums/VideoAlignmentType.enum'; import VideoAlignmentType from '../../../common/enums/VideoAlignmentType.enum';
export interface GetSiteSettingsOptions {
site: string,
isIframe?: boolean,
parentHostname?: string,
}
/** /**
* Contains settings that are currently in effect for a given site. If a certain option * Contains settings that are currently in effect for a given site. If a certain option
* doesn't have a value — or if it has 'default' option, SiteSettings.data will contain * doesn't have a value — or if it has 'default' option, SiteSettings.data will contain
@ -29,7 +22,6 @@ export class SiteSettings {
public get site() { public get site() {
return this._site; return this._site;
} }
private options: GetSiteSettingsOptions;
raw: SiteSettingsInterface; // actual settings raw: SiteSettingsInterface; // actual settings
data: SiteSettingsInterface; // effective settings data: SiteSettingsInterface; // effective settings
@ -41,12 +33,10 @@ export class SiteSettings {
storageChangeSubscriptions: {[x: string]: ((newSiteConf, changes, area) => void)[]} = {}; storageChangeSubscriptions: {[x: string]: ((newSiteConf, changes, area) => void)[]} = {};
//#region lifecycle //#region lifecycle
constructor(settings: Settings, options: GetSiteSettingsOptions) { constructor(settings: Settings, site: string) {
this.options = options;
this.site = options.site;
this.settings = settings; this.settings = settings;
this.raw = settings.active.sites[this.site]; this.raw = settings.active.sites[site];
this.site = site;
this.defaultSettings = settings.active.sites['@global']; this.defaultSettings = settings.active.sites['@global'];
this.compileSettingsObject(); this.compileSettingsObject();
@ -66,53 +56,19 @@ export class SiteSettings {
/** /**
* Tries to match websites, even if we're on a different subdomain. * Tries to match websites, even if we're on a different subdomain.
*
* Priority chain:
*
* START HERE
* |
* [ exact hostname match ]
* | |
* no yes > return settings for hostname
* V
* | matches hostname on |
* | different subdomain? |
* | |
* no yes > return settings for matching subdomain
* V
* [ are we inside of an iframe? ]
* | |
* no yes
* V V
* return default | exact parent |
* settings | hostname match? |
* A | |
* | no yes > [ applyToEmbeddedContent set? ]
* | V | |
* | | parent matches hostname | no yes
* | | on different subdomain? | V V
* | | | use default use parent settings
* +< no yes
* | |
* +< no [ applyToEmbeddedContent set? ]
* |
* yes
* V
* use settings for matching subdomain of parent
*
* @returns * @returns
*/ */
private getSettingsForSite(options: GetSiteSettingsOptions) { private getSettingsForSite() {
if (!options.site) { if (!this.site) {
return { return {
siteSettings: this.settings.active.sites['@global'], siteSettings: this.settings.active.sites['@global'],
usesSettingsFor: '@global' usesSettingsFor: '@global'
}; };
} }
if (this.settings.active.sites[options.site]) { if (this.settings.active.sites[this.site]) {
return { return {
siteSettings: this.settings.active.sites[options.site], siteSettings: this.settings.active.sites[this.site],
usesSettingsFor: undefined usesSettingsFor: undefined
}; };
} }
@ -128,6 +84,7 @@ export class SiteSettings {
// `www.example.com`, this will also match `example.com`, `subdomain.example.com`, `nested.subdomain.example.com` ... // `www.example.com`, this will also match `example.com`, `subdomain.example.com`, `nested.subdomain.example.com` ...
if (configUrlSegments[configUrlSegments.length - 1] === '*' || (configUrlSegments[configUrlSegments.length - 1] === 'www')) { if (configUrlSegments[configUrlSegments.length - 1] === '*' || (configUrlSegments[configUrlSegments.length - 1] === 'www')) {
console.log('ss: comparing', configUrlSegments, urlSegments);
for (let i = 0; i < configUrlSegments.length - 1 && i < urlSegments.length; i++) { for (let i = 0; i < configUrlSegments.length - 1 && i < urlSegments.length; i++) {
if (configUrlSegments[i] !== urlSegments[i]) { if (configUrlSegments[i] !== urlSegments[i]) {
continue siteLoop; continue siteLoop;
@ -140,18 +97,6 @@ export class SiteSettings {
} }
} }
// If we're inside of an iframe, let's see whether we can use parent settings
if (options.isIframe) {
const potentialSettings = this.getSettingsForSite({site: options.parentHostname});
if (potentialSettings.siteSettings.applyToEmbeddedContent !== false) {
if (!potentialSettings.usesSettingsFor) {
potentialSettings.usesSettingsFor = options.parentHostname;
}
return potentialSettings;
}
}
return { return {
siteSettings: this.settings.active.sites['@global'], siteSettings: this.settings.active.sites['@global'],
usesSettingsFor: '@global' usesSettingsFor: '@global'
@ -163,7 +108,7 @@ export class SiteSettings {
* Alan pls ensure default settings object follows the correct structure * Alan pls ensure default settings object follows the correct structure
*/ */
private compileSettingsObject() { private compileSettingsObject() {
const {siteSettings, usesSettingsFor} = this.getSettingsForSite(this.options); const {siteSettings, usesSettingsFor} = this.getSettingsForSite();
this.data = _cp(siteSettings); this.data = _cp(siteSettings);
this.usesSettingsFor = usesSettingsFor; this.usesSettingsFor = usesSettingsFor;

View File

@ -46,6 +46,7 @@ class UI {
this.extensionBase = chrome.runtime.getURL('').replace(/\/$/, ""); this.extensionBase = chrome.runtime.getURL('').replace(/\/$/, "");
// UI will be initialized when setUiVisibility is called // UI will be initialized when setUiVisibility is called
console.log('ui config:', uiConfig);
this.init(); this.init();
} }

View File

@ -1,6 +1,6 @@
import VideoData from './VideoData'; import VideoData from './VideoData';
import RescanReason from './enums/RescanReason.enum'; import RescanReason from './enums/RescanReason.enum';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import CommsClient from '../comms/CommsClient'; import CommsClient from '../comms/CommsClient';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
import { SiteSettings } from '../settings/SiteSettings'; import { SiteSettings } from '../settings/SiteSettings';

View File

@ -24,16 +24,10 @@ interface PlayerDimensions {
interface ElementData { interface ElementData {
element: HTMLElement, element: HTMLElement,
type: string, // kinda forgot what this is being used for type: string,
tagName?: string, tagName?: string,
classList?: any, classList?: any,
id?: string id?: string
width?: number;
height?: number;
heuristics?: any;
index?: number,
autoScore?: number;
} }
type ElementStack = ElementData[]; type ElementStack = ElementData[];
@ -278,6 +272,7 @@ class PlayerData {
return; return;
} }
if ( if (
this.isFullscreen this.isFullscreen
|| ( || (
@ -387,8 +382,6 @@ class PlayerData {
try { try {
// get player dimensions _once_ // get player dimensions _once_
let currentPlayerDimensions; let currentPlayerDimensions;
let fsChanged = this.isFullscreen !== !!document.fullscreenElement;
this.isFullscreen = !!document.fullscreenElement; this.isFullscreen = !!document.fullscreenElement;
if (this.isFullscreen) { if (this.isFullscreen) {
@ -431,10 +424,6 @@ class PlayerData {
// Save current dimensions to avoid triggering this function pointlessly // Save current dimensions to avoid triggering this function pointlessly
this.dimensions = currentPlayerDimensions; this.dimensions = currentPlayerDimensions;
if (fsChanged) {
this.updatePlayer();
}
} catch (e) { } catch (e) {
} }
@ -573,21 +562,19 @@ class PlayerData {
//#endregion //#endregion
private getElementStack(): ElementStack { private getElementStack(): ElementStack {
const elementStack: ElementStack = [{ const elementStack: any[] = [{
element: this.videoElement, element: this.videoElement,
type: 'video', type: 'video',
tagName: 'video', tagName: 'video',
classList: this.videoElement.classList, classList: this.videoElement.classList,
id: this.videoElement.id, id: this.videoElement.id,
}]; }];
let element = this.videoElement.parentNode as HTMLElement; let element = this.videoElement.parentNode as HTMLElement;
// first pass to generate the element stack and translate it into array // first pass to generate the element stack and translate it into array
while (element) { while (element) {
elementStack.push({ elementStack.push({
element, element,
type: '',
tagName: element.tagName, tagName: element.tagName,
classList: element.classList, classList: element.classList,
id: element.id, id: element.id,
@ -718,31 +705,21 @@ class PlayerData {
* @param videoHeight * @param videoHeight
* @returns * @returns
*/ */
private getPlayerAuto(elementStack: ElementStack, videoWidth, videoHeight) { private getPlayerAuto(elementStack: any[], videoWidth, videoHeight) {
let penaltyMultiplier = 2; let penaltyMultiplier = 1;
const sizePenaltyMultiplier = 0.1; const sizePenaltyMultiplier = 0.1;
const perLevelScorePenalty = 10; const perLevelScorePenalty = 10;
let sameSizeBonus = 0; let sameSizeBonus = 0;
const fullscreenElement = document.fullscreenElement; for (const [index, element] of elementStack.entries()) {
element.index = index;
for (const [index, elementData] of elementStack.entries()) {
elementData.index = index;
// ignore weird elements, those would break our stuff // ignore weird elements, those would break our stuff
if (elementData.width == 0 || elementData.height == 0) { if (element.width == 0 || element.height == 0) {
elementData.heuristics['invalidSize'] = true; element.heuristics['invalidSize'] = true;
continue; continue;
} }
if (elementData.element === fullscreenElement) {
// reset penalty multiplier if current element is full screen element
// penaltyMultiplier here must be smaller than initial penalty multiplier,
// so that playerElement is not above fullscreenElement. Player element must
// be a descendant of fullscreenElement for the UI to show up
penaltyMultiplier = 1;
}
// element is player, if at least one of the sides is as long as the video // element is player, if at least one of the sides is as long as the video
// note that we can't make any additional assumptions with regards to player // note that we can't make any additional assumptions with regards to player
// size, since there are both cases where the other side is bigger _and_ cases // size, since there are both cases where the other side is bigger _and_ cases
@ -751,8 +728,8 @@ class PlayerData {
// Don't bother thinking about this too much, as any "thinking" was quickly // Don't bother thinking about this too much, as any "thinking" was quickly
// corrected by bugs caused by various edge cases. // corrected by bugs caused by various edge cases.
if ( if (
this.equalish(elementData.height, videoHeight, 5) this.equalish(element.height, videoHeight, 5)
|| this.equalish(elementData.width, videoWidth, 5) || this.equalish(element.width, videoWidth, 5)
) { ) {
let score = 1000; let score = 1000;
@ -763,8 +740,8 @@ class PlayerData {
// Our ideal player will be as close to the video element, and it will als // Our ideal player will be as close to the video element, and it will als
// be as close to the size of the video. // be as close to the size of the video.
const diffX = (elementData.width - videoWidth); const diffX = (element.width - videoWidth);
const diffY = (elementData.height - videoHeight); const diffY = (element.height - videoHeight);
// we have a minimal amount of grace before we start dinking scores for // we have a minimal amount of grace before we start dinking scores for
// mismatched dimensions. The size of the dimension mismatch dink is // mismatched dimensions. The size of the dimension mismatch dink is
@ -783,14 +760,14 @@ class PlayerData {
// candidate gets dinked a bit // candidate gets dinked a bit
// score -= perLevelScorePenalty * penaltyMultiplier; // score -= perLevelScorePenalty * penaltyMultiplier;
if (elementData.width === elementStack[index - 1].width && elementData.height === elementStack[index - 1].height) { if (element.width === elementStack[index - 1].width && element.height === elementStack[index - 1].height) {
score += ++sameSizeBonus; score += ++sameSizeBonus;
} else { } else {
sameSizeBonus = 0; sameSizeBonus = 0;
} }
elementData.autoScore = score; element.autoScore = score;
elementData.heuristics['autoScoreDetails'] = { element.heuristics['autoScoreDetails'] = {
playerSizePenalty, playerSizePenalty,
diffX, diffX,
diffY, diffY,

View File

@ -2,7 +2,7 @@ import PlayerData from './PlayerData';
import Resizer from '../video-transform/Resizer'; import Resizer from '../video-transform/Resizer';
import * as _ from 'lodash'; import * as _ from 'lodash';
import BrowserDetect from '../../conf/BrowserDetect'; import BrowserDetect from '../../conf/BrowserDetect';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import PageInfo from './PageInfo'; import PageInfo from './PageInfo';
import { sleep } from '../../../common/js/utils'; import { sleep } from '../../../common/js/utils';
import { hasDrm } from '../ar-detect/DrmDetecor'; import { hasDrm } from '../ar-detect/DrmDetecor';

View File

@ -9,7 +9,7 @@ import AspectRatioType from '../../../common/enums/AspectRatioType.enum';
import VideoData from '../video-data/VideoData'; import VideoData from '../video-data/VideoData';
import EventBus from '../EventBus'; import EventBus from '../EventBus';
import { _cp } from '../../../common/js/utils'; import { _cp } from '../../../common/js/utils';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import { Ar, ArVariant } from '../../../common/interfaces/ArInterface'; import { Ar, ArVariant } from '../../../common/interfaces/ArInterface';
import { RunLevel } from '../../enum/run-level.enum'; import { RunLevel } from '../../enum/run-level.enum';
import * as _ from 'lodash'; import * as _ from 'lodash';
@ -233,7 +233,7 @@ class Resizer {
} }
prepareCss(css: string): string { prepareCss(css) {
return `.${this.userCssClassName} {${css}}`; return `.${this.userCssClassName} {${css}}`;
} }
@ -242,11 +242,11 @@ class Resizer {
this.destroyed = true; this.destroyed = true;
} }
getFileAr(): number { getFileAr() {
return this.videoData.video.videoWidth / this.videoData.video.videoHeight; return this.videoData.video.videoWidth / this.videoData.video.videoHeight;
} }
calculateRatioForLegacyOptions(ar: Ar): Ar | null { calculateRatioForLegacyOptions(ar){
// also present as modeToAr in Scaler.js // also present as modeToAr in Scaler.js
if (ar.type !== AspectRatioType.FitWidth && ar.type !== AspectRatioType.FitHeight && ar.ratio) { if (ar.type !== AspectRatioType.FitWidth && ar.type !== AspectRatioType.FitHeight && ar.ratio) {
return ar; return ar;
@ -358,7 +358,7 @@ class Resizer {
this.videoData.videoUnloaded(); this.videoData.videoUnloaded();
} }
this.logger.info('setAr', `<rid:${this.resizerId}> trying to set ar. New ar:`, ar, 'last ar override was', lastAr ? '' : 'NOT', 'provided:', lastAr); this.logger.info('setAr', `<rid:${this.resizerId}> trying to set ar. New ar:`, ar);
let stretchFactors: VideoDimensions | any; let stretchFactors: VideoDimensions | any;

View File

@ -1,7 +1,7 @@
import { SiteSettings } from './../settings/SiteSettings'; import { SiteSettings } from './../settings/SiteSettings';
import BrowserDetect from '../../conf/BrowserDetect'; import BrowserDetect from '../../conf/BrowserDetect';
import VideoData from '../video-data/VideoData'; import VideoData from '../video-data/VideoData';
import Settings from '../settings/Settings'; import Settings from '../Settings';
import { Stretch } from '../../../common/interfaces/StretchInterface'; import { Stretch } from '../../../common/interfaces/StretchInterface';
import { ComponentLogger } from '../logging/ComponentLogger'; import { ComponentLogger } from '../logging/ComponentLogger';

View File

@ -1,49 +0,0 @@
/**
* Reqzests iframe parent hostname
* @returns
*/
export async function getIframeParentHost(): Promise<string> {
return new Promise<any>((resolve) => {
let resolved = false;
let resendInterval;
function handleMessage(event) {
if (event.data.action === 'uw-parent-hostname') {
resolved = true;
clearInterval(resendInterval);
window.removeEventListener('message', handleMessage);
resolve(event.data.hostname);
}
}
window.addEventListener('message', handleMessage);
resendInterval = setInterval(
() => {
if (!resolved) {
window.parent.postMessage(
{ action: 'uw-get-parent-hostname' },
'*'
);
}
},
500
);
});
}
function handleMessage(event) {
if (event.data.action === 'uw-get-parent-hostname') {
event.source.postMessage(
{action: 'uw-parent-hostname', hostname: window.location.hostname},
'*' as any
)
}
}
export async function setupHostnameReporting() {
window.removeEventListener('message', handleMessage); // setupHostnameReporting may run more than once
window.addEventListener('message', handleMessage);
}

View File

@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "Ultrawidify", "name": "Ultrawidify",
"description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.", "description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.",
"version": "6.3.9", "version": "6.3.0",
"icons": { "icons": {
"32":"res/icons/uw-32.png", "32":"res/icons/uw-32.png",
"64":"res/icons/uw-64.png" "64":"res/icons/uw-64.png"

View File

@ -111,7 +111,7 @@
<script> <script>
import Donate from '../common/misc/Donate.vue'; import Donate from '../common/misc/Donate.vue';
import SuperAdvancedSettings from './SuperAdvancedSettings.vue'; import SuperAdvancedSettings from './SuperAdvancedSettings.vue';
import Settings from '../ext/lib/settings/Settings'; import Settings from '../ext/lib/Settings';
import GeneralSettings from './GeneralSettings'; import GeneralSettings from './GeneralSettings';
import ControlsSettings from './controls-settings/ControlsSettings'; import ControlsSettings from './controls-settings/ControlsSettings';
import AddEditActionPopup from './controls-settings/AddEditActionPopup'; import AddEditActionPopup from './controls-settings/AddEditActionPopup';

View File

@ -33,7 +33,7 @@
<script> <script>
import BrowserDetect from '../ext/conf/BrowserDetect'; import BrowserDetect from '../ext/conf/BrowserDetect';
import Settings from '../ext/lib/settings/Settings'; import Settings from '../ext/lib/Settings';
export default { export default {
data() { data() {