Compare commits
No commits in common. "3d8d8eb19924be2e988fbb788fab748e0305558c" and "c9818c92b36105b1550725c364e228b2b77c7884" have entirely different histories.
3d8d8eb199
...
c9818c92b3
@ -446,8 +446,6 @@ interface SettingsInterface {
|
||||
}
|
||||
|
||||
export interface SiteSettingsInterface {
|
||||
notes?: string; // any special things related to this site.
|
||||
|
||||
enable: ExtensionMode;
|
||||
enableAard: ExtensionMode;
|
||||
enableKeyboard: InputHandlingMode;
|
||||
|
||||
@ -120,12 +120,9 @@ export default class UWContent {
|
||||
|
||||
this.logger.debug('setup', "KeyboardHandler initiated.");
|
||||
|
||||
if (this.globalUi) {
|
||||
this.globalUi.destroy();
|
||||
}
|
||||
// this.globalUi = new UI('ultrawidify-global-ui', {eventBus: this.eventBus, isGlobal: true});
|
||||
// this.globalUi.enable();
|
||||
// this.globalUi.setUiVisibility(false);
|
||||
this.globalUi = new UI('ultrawidify-global-ui', {eventBus: this.eventBus, isGlobal: true});
|
||||
this.globalUi.enable();
|
||||
this.globalUi.setUiVisibility(false);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Ultrawidify: failed to start extension. Error:', e)
|
||||
|
||||
@ -9,7 +9,6 @@ import LegacyExtensionMode from '@src/common/enums/LegacyExtensionMode.enum';
|
||||
import { PlayerDetectionMode } from '@src/common/enums/PlayerDetectionMode.enum';
|
||||
import { SiteSupportLevel } from '@src/common/enums/SiteSupportLevel.enum';
|
||||
import SettingsInterface from '@src/common/interfaces/SettingsInterface';
|
||||
import { _cp } from '@src/common/utils/_cp';
|
||||
import { update } from 'lodash';
|
||||
|
||||
|
||||
@ -479,13 +478,6 @@ const ExtensionConfPatch = Object.freeze([
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
forVersion: '6.3.998',
|
||||
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface, logger?) => {
|
||||
if (!userOptions.sites["www.amazon.com"]) {
|
||||
userOptions.sites["www.amazon.com"] = _cp(defaultOptions.sites["www.amazon.com"] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]);
|
||||
|
||||
@ -983,29 +983,6 @@ const ExtensionConf: SettingsInterface = {
|
||||
}
|
||||
}
|
||||
},
|
||||
"www.amazon.com": {
|
||||
enable: ExtensionMode.Default,
|
||||
enableAard: ExtensionMode.Default,
|
||||
enableKeyboard: InputHandlingMode.Enabled,
|
||||
enableUI: ExtensionMode.Default,
|
||||
applyToEmbeddedContent: EmbeddedContentSettingsOverridePolicy.Default,
|
||||
overrideWhenEmbedded: EmbeddedContentSettingsOverridePolicy.Default,
|
||||
type: SiteSupportLevel.CommunitySupport,
|
||||
defaultType: SiteSupportLevel.CommunitySupport,
|
||||
persistCSA: CropModePersistence.Default,
|
||||
activeDOMConfig: "@community",
|
||||
DOMConfig: {
|
||||
"@community": {
|
||||
type: SiteSupportLevel.CommunitySupport,
|
||||
elements: {
|
||||
player: {
|
||||
detectionMode: PlayerDetectionMode.Auto,
|
||||
allowAutoFallback: true
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
"www.twitch.tv": {
|
||||
enable: ExtensionMode.All,
|
||||
enableAard: ExtensionMode.All,
|
||||
|
||||
@ -107,6 +107,10 @@ export default class EventBus {
|
||||
eventBusCommand.function(commandData, context);
|
||||
}
|
||||
}
|
||||
if (context.commandId) {
|
||||
const i = this.lastExecutedCommandIndex++ % this.lastExecutedCommandIds.length;
|
||||
this.lastExecutedCommandIds[i] = context.commandId;
|
||||
}
|
||||
|
||||
// preventing messages from flowing back to their original senders is
|
||||
// CommsServer's job. EventBus does not have enough data for this decision.
|
||||
@ -115,11 +119,6 @@ export default class EventBus {
|
||||
if (!context.commandId) {
|
||||
context.commandId = crypto.randomUUID();
|
||||
}
|
||||
if (context.commandId) {
|
||||
const i = this.lastExecutedCommandIndex++ % this.lastExecutedCommandIds.length;
|
||||
this.lastExecutedCommandIds[i] = context.commandId;
|
||||
}
|
||||
|
||||
if (
|
||||
this.comms
|
||||
&& context?.origin !== CommsOrigin.Server
|
||||
@ -144,21 +143,12 @@ export default class EventBus {
|
||||
...context,
|
||||
borderCrossings: {
|
||||
...context?.borderCrossings,
|
||||
// iframe: true // we actually no longer check this prop, we should instead rely on visitedBusses
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// send to parent iframe
|
||||
if (!this.disableTunnel && typeof window !== 'undefined') {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
action: 'uw-bus-tunnel',
|
||||
payload: {command, config: commandData, context} as EventBusMessage
|
||||
},
|
||||
'*'
|
||||
);
|
||||
}
|
||||
this.sendToTunnel(command, commandData, context);
|
||||
|
||||
if (context?.stopPropagation) {
|
||||
return;
|
||||
@ -166,6 +156,52 @@ export default class EventBus {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
* Send, but intended for sending commands from iframe to content scripts
|
||||
* @param command
|
||||
* @param config
|
||||
*/
|
||||
private sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
|
||||
if (!context.visitedBusses) {
|
||||
// this should never trigger on production version of the extension.
|
||||
console.error('Visited busses is missing from context. This is illegal.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.disableTunnel && typeof window !== 'undefined') {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
action: 'uw-bus-tunnel',
|
||||
payload: {command, config, context} as EventBusMessage
|
||||
},
|
||||
'*'
|
||||
);
|
||||
} else {
|
||||
// because iframe UI components get reused in the popup, we
|
||||
// also need to set up a detour because the tunnel is closed
|
||||
// in the popup
|
||||
if (this.comms) {
|
||||
try {
|
||||
this.comms.sendMessage(
|
||||
{
|
||||
command,
|
||||
config,
|
||||
context: {
|
||||
...this.popupContext,
|
||||
...context
|
||||
}
|
||||
},
|
||||
this.popupContext
|
||||
);
|
||||
} catch (e) {
|
||||
if (command !== 'reload-required') {
|
||||
this.send('reload-required', {}, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#region iframe tunnelling
|
||||
private setupIframeTunnelling() {
|
||||
// forward messages coming from iframe tunnels
|
||||
|
||||
@ -176,7 +176,7 @@ class CommsServer {
|
||||
if (context?.comms.forwardTo === 'all') {
|
||||
return this.sendToAll(message);
|
||||
}
|
||||
if (context?.comms.forwardTo === 'active' || !context?.comms.forwardTo) {
|
||||
if (context?.comms.forwardTo === 'active') {
|
||||
return this.sendToActive(message);
|
||||
}
|
||||
if (context?.comms.forwardTo === 'contentScript') {
|
||||
|
||||
@ -19,8 +19,6 @@ import { UwuiWindow } from './UwuiWindow';
|
||||
|
||||
import { createApp } from 'vue';
|
||||
import SettingsWindowContent from '@components/SettingsWindowContent.vue';
|
||||
import { Ar } from '@src/common/interfaces/ArInterface';
|
||||
import { Stretch } from '@src/common/interfaces/StretchInterface';
|
||||
// import jsonEditorCSS from 'vanilla-jsoneditor/themes/jse-theme-dark.css?inline'
|
||||
|
||||
if (process.env.CHANNEL !== 'stable'){
|
||||
@ -41,9 +39,6 @@ class UI {
|
||||
private extensionMenu: ClientMenu;
|
||||
private logger: ComponentLogger;
|
||||
|
||||
private forwardedCommandIds: string[] = new Array(64);
|
||||
private lastForwardedCommandIndex = 0;
|
||||
|
||||
private uiState = {
|
||||
lockXY: true,
|
||||
zoom: { // log2 scale — 100% is 0
|
||||
@ -95,12 +90,6 @@ class UI {
|
||||
function: (commandData, context) => {
|
||||
this.createSettingsWindow(commandData?.initialState);
|
||||
}
|
||||
},
|
||||
|
||||
'broadcast-scaling-params': {
|
||||
function: (commandData: {effectiveZoom: {x: number, y: number}, lastAr: Ar, stretch: Stretch}, context) => {
|
||||
console.warn('got scaling params:', commandData)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -132,7 +121,7 @@ class UI {
|
||||
|
||||
private initMessaging() {
|
||||
if (this.messageListener) {
|
||||
this.destroyMessaging();
|
||||
window.removeEventListener('message', this.messageListener);
|
||||
} else {
|
||||
this.messageListener = (event: MessageEvent) => {
|
||||
const data = event.data;
|
||||
@ -144,26 +133,7 @@ class UI {
|
||||
|
||||
const payload = data.payload;
|
||||
|
||||
/**
|
||||
* it appears that forwarded commands can be multiplying to ridiculous degree,
|
||||
* but i didn't find anything that would obviously cause the message forwarding storm
|
||||
* this means we'll try to avoid that via brute force.
|
||||
*
|
||||
* How bad is it?
|
||||
* — can get as bad as 100k messages a minute (!)
|
||||
*/
|
||||
if (!payload.context?.commandId) {
|
||||
// user should never see this log
|
||||
console.warn('Command context does not contain commandId. This is illegal. Message will not be forwarded.', {payload});
|
||||
return;
|
||||
}
|
||||
if (this.forwardedCommandIds.includes(payload.context.commandId)) {
|
||||
console.warn('this command was already forwarded, doing nothing:', {payload});
|
||||
return;
|
||||
}
|
||||
const i = this.lastForwardedCommandIndex++ % this.forwardedCommandIds.length;
|
||||
this.forwardedCommandIds[i] = payload.id;
|
||||
|
||||
console.log('forwarding from tunnel to event bus. payload', payload);
|
||||
|
||||
// Forward to all iframes except the source
|
||||
(UwuiWindow as any).instances?.forEach(win => {
|
||||
@ -184,12 +154,6 @@ class UI {
|
||||
window.addEventListener('message', this.messageListener);
|
||||
}
|
||||
|
||||
private destroyMessaging() {
|
||||
if (this.messageListener) {
|
||||
window.removeEventListener('message', this.messageListener);
|
||||
}
|
||||
}
|
||||
|
||||
executeCommand(x: CommandInterface) {
|
||||
this.eventBus.send(x.action, x.arguments);
|
||||
}
|
||||
@ -547,6 +511,10 @@ class UI {
|
||||
});
|
||||
}
|
||||
|
||||
setUiVisibility(visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
async enable() {
|
||||
// if root element is not present, we need to init the UI.
|
||||
// if (!this.rootDiv) {
|
||||
@ -567,7 +535,6 @@ class UI {
|
||||
* @param {*} newUiConfig
|
||||
*/
|
||||
replace(newUiConfig) {
|
||||
this.destroy();
|
||||
this.uiConfig = newUiConfig;
|
||||
this.init();
|
||||
}
|
||||
@ -576,7 +543,6 @@ class UI {
|
||||
if (this.extensionMenu) {
|
||||
this.extensionMenu.destroy();
|
||||
}
|
||||
this.destroyMessaging();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -195,10 +195,6 @@ class PlayerData {
|
||||
|
||||
//#region lifecycle
|
||||
constructor(videoData) {
|
||||
if (!(window as any).uiCount) {
|
||||
(window as any).uiCount = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
// set all our helper objects
|
||||
this.logger = new ComponentLogger(videoData.logAggregator, 'PlayerData', {styles: {}});
|
||||
@ -879,9 +875,7 @@ class PlayerData {
|
||||
bestCandidate.heuristics['qsMatch'] = true;
|
||||
}
|
||||
|
||||
if (bestCandidate) {
|
||||
bestCandidate.heuristics['activePlayer'] = true;
|
||||
}
|
||||
bestCandidate.heuristics['activePlayer'] = true;
|
||||
return bestCandidate;
|
||||
}
|
||||
|
||||
|
||||
@ -298,16 +298,33 @@ class VideoData {
|
||||
|
||||
initializeObservers() {
|
||||
try {
|
||||
this.observer = new ResizeObserver(
|
||||
_.debounce(
|
||||
() => this.onVideoDimensionsChanged,
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
)
|
||||
);
|
||||
if (BrowserDetect.firefox) {
|
||||
this.observer = new ResizeObserver(
|
||||
_.debounce(
|
||||
this.onVideoDimensionsChanged,
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Chrome for some reason insists that this.onPlayerDimensionsChanged is not a function
|
||||
// when it's not wrapped into an anonymous function
|
||||
this.observer = new ResizeObserver(
|
||||
_.debounce(
|
||||
(m, o) => {
|
||||
this.onVideoDimensionsChanged(m, o)
|
||||
},
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[VideoData] Observer setup failed:', e);
|
||||
}
|
||||
@ -315,20 +332,34 @@ class VideoData {
|
||||
}
|
||||
|
||||
setupMutationObserver() {
|
||||
if (this.mutationObserver) {
|
||||
this.mutationObserver.disconnect();
|
||||
}
|
||||
try {
|
||||
this.mutationObserver = new MutationObserver(
|
||||
_.debounce(
|
||||
() => this.onVideoMutation(),
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
if (BrowserDetect.firefox) {
|
||||
this.mutationObserver = new MutationObserver(
|
||||
_.debounce(
|
||||
this.onVideoMutation,
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
// Chrome for some reason insists that this.onPlayerDimensionsChanged is not a function
|
||||
// when it's not wrapped into an anonymous function
|
||||
this.mutationObserver = new MutationObserver(
|
||||
_.debounce(
|
||||
(m, o) => {
|
||||
this.onVideoMutation(m, o)
|
||||
},
|
||||
250,
|
||||
{
|
||||
leading: true,
|
||||
trailing: true
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[VideoData] Observer setup failed:', e);
|
||||
}
|
||||
@ -341,17 +372,6 @@ class VideoData {
|
||||
destroy() {
|
||||
this.logger.info('destroy', `<vdid:${this.vdid}> received destroy command`);
|
||||
|
||||
// Disconnect observer and set destroyed to 'true' _before_ removing classes from
|
||||
// the video element
|
||||
|
||||
this.destroyed = true;
|
||||
try {
|
||||
this.observer.disconnect();
|
||||
} catch (e) {}
|
||||
try {
|
||||
this.mutationObserver.disconnect();
|
||||
} catch (e) {}
|
||||
|
||||
if (this.video) {
|
||||
this.video.classList.remove(this.userCssClassName);
|
||||
this.video.classList.remove('uw-ultrawidify-base-wide-screen');
|
||||
@ -361,6 +381,8 @@ class VideoData {
|
||||
this.video.removeEventListener('ontimeupdate', this.onTimeUpdate);
|
||||
}
|
||||
|
||||
this.eventBus.send('set-run-level', RunLevel.Off);
|
||||
this.destroyed = true;
|
||||
this.eventBus.unsubscribeAll(this);
|
||||
|
||||
try {
|
||||
@ -375,6 +397,9 @@ class VideoData {
|
||||
try {
|
||||
this.player.destroy();
|
||||
} catch (e) {}
|
||||
try {
|
||||
this.observer.disconnect();
|
||||
} catch (e) {}
|
||||
this.player = undefined;
|
||||
this.video = undefined;
|
||||
}
|
||||
@ -438,7 +463,7 @@ class VideoData {
|
||||
|
||||
this.runLevel = runLevel;
|
||||
if (!options?.fromPlayer) {
|
||||
this.player?.setRunLevel(runLevel);
|
||||
this.player.setRunLevel(runLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,10 +532,6 @@ class VideoData {
|
||||
}
|
||||
|
||||
onVideoMutation(mutationList?: MutationRecord[], observer?) {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// verify that mutation didn't remove our class. Some pages like to do that.
|
||||
let confirmAspectRatioRestore = false;
|
||||
|
||||
|
||||
@ -495,14 +495,8 @@ class Resizer {
|
||||
try {
|
||||
const translate = this.computeOffsets(stretchFactors, options?.ar);
|
||||
this.applyCss(stretchFactors, translate);
|
||||
|
||||
this.eventBus.send('broadcast-scaling-params', {
|
||||
effectiveZoom: {x: stretchFactors.xFactor, y: stretchFactors.yFactor},
|
||||
lastAr: this.lastAr,
|
||||
stretch: this.stretcher.stretch
|
||||
});
|
||||
} catch (e) {
|
||||
this.logger.warn('applyScaling', 'error while applying CSS:', e);
|
||||
this.logger.warn('setAr', 'error while applying CSS:', e);
|
||||
// don't apply CSS if there's an error
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user