diff --git a/src/common/components/shortcut-button.vue b/src/common/components/shortcut-button.vue new file mode 100644 index 0000000..ea3ca21 --- /dev/null +++ b/src/common/components/shortcut-button.vue @@ -0,0 +1,28 @@ + + + + {{label}} + + + + {{shortcut ? `(${shortcut})` : ''}} + + + + + + + + diff --git a/src/ext/conf/Debug.js b/src/ext/conf/Debug.js index 4c62cf7..a35b740 100644 --- a/src/ext/conf/Debug.js +++ b/src/ext/conf/Debug.js @@ -13,11 +13,11 @@ var Debug = { // comms: false, comms: true, // showArDetectCanvas: true, - flushStoredSettings: true, - // flushStoredSettings: false, + // flushStoredSettings: true, + flushStoredSettings: false, playerDetectDebug: true, periodic: true, - videoRescan: true, + // videoRescan: true, mousemove: true, arDetect: { edgeDetect: true @@ -48,8 +48,6 @@ function __disableAllDebug(obj) { } } -Debug = Debug; - if(Debug.debug) console.log("Guess we're debugging ultrawidify then. Debug.js must always load first, and others must follow.\nLoading: Debug.js"); diff --git a/src/ext/lib/ActionHandler.js b/src/ext/lib/ActionHandler.js index cfc44d3..9b590b3 100644 --- a/src/ext/lib/ActionHandler.js +++ b/src/ext/lib/ActionHandler.js @@ -1,6 +1,5 @@ import Debug from '../conf/Debug'; import PlayerData from './video-data/PlayerData'; -import Comms from './comms/Comms'; class ActionHandler { @@ -221,6 +220,8 @@ class ActionHandler { } } + // če smo našli dejanje za to tipko, potem ne preiskujemo naprej + // if we found an action for this key, we stop searching for a match return; } } diff --git a/src/ext/lib/ObjectCopy.js b/src/ext/lib/ObjectCopy.js index 926a39a..398d26e 100644 --- a/src/ext/lib/ObjectCopy.js +++ b/src/ext/lib/ObjectCopy.js @@ -1,3 +1,5 @@ +import Debug from '../conf/Debug'; + class ObjectCopy { static addNew(existing, target){ diff --git a/src/ext/lib/Settings.js b/src/ext/lib/Settings.js index 3c585ed..4fce3c9 100644 --- a/src/ext/lib/Settings.js +++ b/src/ext/lib/Settings.js @@ -2,6 +2,7 @@ import Debug from '../conf/Debug'; import currentBrowser from '../conf/BrowserDetect'; import ExtensionConf from '../conf/ExtensionConf'; import ExtensionMode from '../../common/enums/extension-mode'; +import ObjectCopy from '../lib/ObjectCopy'; class Settings { diff --git a/src/ext/lib/comms/CommsServer.js b/src/ext/lib/comms/CommsServer.js index 375eb16..98c806f 100644 --- a/src/ext/lib/comms/CommsServer.js +++ b/src/ext/lib/comms/CommsServer.js @@ -1,5 +1,5 @@ import Debug from '../../conf/Debug'; -import BrowserDetect from '../../conf/Debug'; +import BrowserDetect from '../../conf/BrowserDetect'; class CommsServer { constructor(server) { @@ -9,12 +9,14 @@ class CommsServer { var ths = this; + console.log("[CommsServer::ctor] INIT! are we in ff?", BrowserDetect.firefox, "BrowserDetect says ...", BrowserDetect) + if (BrowserDetect.firefox) { browser.runtime.onConnect.addListener(p => ths.onConnect(p)); browser.runtime.onMessage.addListener(m => ths.processReceivedMessage_nonpersistent_ff(m)); } else { chrome.runtime.onConnect.addListener(p => ths.onConnect(p)); - chrome.runtime.onMessage.addListener((msg, sender, callback) => ths.processReceivedMessage_nonpersistent_chrome(m, sender, callback)); + chrome.runtime.onMessage.addListener((m, sender, callback) => ths.processReceivedMessage_nonpersistent_chrome(m, sender, callback)); } } @@ -136,7 +138,15 @@ class CommsServer { async processReceivedMessage(message, port){ if (Debug.debug && Debug.comms) { - console.log("[CommsServer.js::processMessage] Received message from background script!", message, "port", port, "\nsettings and server:", this.settings,this.server); + console.log("[CommsServer.js::processReceivedMessage] Received message from popup/content script!", message, "port", port, "\nsettings and server:", this.settings,this.server); + } + + if (message.forwardToContentScript) { + if (Debug.debug && Debug.comms) { + console.log("[CommsServer.js::processReceivedMessage] Message has 'forward to content script' flag set. Forwarding message as is. Message:", message); + } + + this.sendToFrame(message, message.targetFrame); } if (message.cmd === 'announce-zoom') { @@ -162,33 +172,11 @@ class CommsServer { console.log("CommsServer: received get-config. Active settings?", this.settings.active, "\n(settings:", this.settings, ")") } port.postMessage({cmd: "set-config", conf: this.settings.active, site: this.server.currentSite}) - } else if (message.cmd === 'set-stretch') { - this.sendToFrame(message, message.targetFrame); - } else if (message.cmd === 'set-ar') { - this.sendToFrame(message, message.targetFrame); - } else if (message.cmd === 'set-alignment') { - this.sendToFrame(message, message.targetFrame); - } else if (message.cmd === 'autoar-start') { - this.sendToFrame(message, message.targetFrame); - } else if (message.cmd === "autoar-disable") { // LEGACY - can be removed prolly - this.settings.active.arDetect.mode = "disabled"; - if(message.reason){ - this.settings.active.arDetect.disabledReason = message.reason; - } else { - this.settings.active.arDetect.disabledReason = 'User disabled'; - } - this.settings.save(); - } else if (message.cmd === 'set-zoom') { - this.sendToFrame(message, message.targetFrame); } else if (message.cmd === 'has-video') { this.server.registerVideo(port.sender); } else if (message.cmd === 'noVideo') { this.server.unregisterVideo(port.sender); - } else if (message.cmd === 'mark-player') { - this.sendToFrame(message, message.targetTab, message.targetFrame); - } else if (message.cmd === 'unmark-player') { - this.sendToAll(message); - } + } } processReceivedMessage_nonpersistent_ff(message, sender){ @@ -196,6 +184,15 @@ class CommsServer { console.log("%c[CommsServer.js::processMessage_nonpersistent_ff] Received message from background script!", "background-color: #11D; color: #aad", message, sender); } + if (message.forwardToContentScript) { + if (Debug.debug && Debug.comms) { + console.log("[CommsServer.js::processMessage_nonpersistent_ff] Message has 'forward to content script' flag set. Forwarding message as is. Message:", message); + console.log("[CommsServer.js::processMessage_nonpersistent_ff] (btw we probably shouldn't be seeing this. This should prolly happen in persistent connection?"); + } + + this.sendToFrame(message, message.targetFrame); + } + if (message.cmd === 'get-config') { var ret = {extensionConf: JSON.stringify(this.settings.active)}; if (Debug.debug && Debug.comms) { @@ -236,6 +233,10 @@ class CommsServer { processReceivedMessage_nonpersistent_chrome(message, sender, sendResponse){ if (Debug.debug && Debug.comms) { console.log("[CommsServer.js::processMessage_nonpersistent_chrome] Received message from background script!", message); + + if (BrowserDetect.firefox) { + throw "WHAT THE FUCK WHY IS THIS RUNNING, THIS ISNT SUPPOSED TO BE RUNNING RN" + } } if(message.cmd === 'get-config') { diff --git a/src/options/options.js b/src/options/options.js index a946b03..8d0c61b 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -1,8 +1,6 @@ // console.log("global browser", browser, global.browser) // global.browser = require('webextension-polyfill') - - import Vue from 'vue' import App from './App' diff --git a/src/popup/App.vue b/src/popup/App.vue index f239452..a0b3f1a 100644 --- a/src/popup/App.vue +++ b/src/popup/App.vue @@ -1,13 +1,44 @@ - Hello world! + + Ultrawidify: Quick settings + + + + + + + + + + + diff --git a/src/popup/js/ExecAction.js b/src/popup/js/ExecAction.js new file mode 100644 index 0000000..aacc52e --- /dev/null +++ b/src/popup/js/ExecAction.js @@ -0,0 +1,49 @@ +import Comms from '../../ext/lib/comms/Comms'; + +class ExecAction { + constructor(settings) { + this.settings = settings; + } + + setSettings(settings) { + this.settings = settings; + } + + exec(action, scope, frame) { + for (var cmd of action.cmd) { + if (scope === 'page') { + const message = { + forwardToContentScript: true, + targetFrame: frame, + cmd: cmd.action, + arg: cmd.arg + } + Comms.sendMessage(message); + } else if (scope === 'site') { + if (cmd.action === "set-stretch") { + this.settings.active.sites[window.location.host].stretch = cmd.arg; + } else if (cmd.action === "set-alignment") { + this.settings.active.sites[window.location.host].videoAlignment = cmd.arg; + } else if (cmd.action === "set-extension-mode") { + this.settings.active.sites[window.location.host].status = cmd.arg; + } else if (cmd.action === "set-autoar-mode") { + this.settings.active.sites[window.location.host].arStatus = cmd.arg; + } + this.settings.save(); + } else if (scope === 'global') { + if (cmd.action === "set-stretch") { + this.settings.active.stretch.initialMode = cmd.arg; + } else if (cmd.action === "set-alignment") { + this.settings.active.miscSettings.videoAlignment = cmd.arg; + } else if (cmd.action === "set-extension-mode") { + this.settings.active.extensionMode = cmd.arg; + } else if (cmd.action === "set-autoar-mode") { + this.settings.active.arDetect.mode.arStatus = cmd.arg; + } + this.settings.save(); + } + } + } +} + +export default ExecAction; diff --git a/src/popup/panels/AboutPanel.vue b/src/popup/panels/AboutPanel.vue new file mode 100644 index 0000000..f7cc402 --- /dev/null +++ b/src/popup/panels/AboutPanel.vue @@ -0,0 +1,23 @@ + + + + Ultrawidify version: {{addonVersion}} + + + Having an issue? Report undocumented features bugs using one of the following options: + + Github (strongly preferred) + PM me on reddit + Email: tamius.han@gmail.com + + + + + + diff --git a/src/popup/panels/DonatePanel.vue b/src/popup/panels/DonatePanel.vue new file mode 100644 index 0000000..f8afe6a --- /dev/null +++ b/src/popup/panels/DonatePanel.vue @@ -0,0 +1,5 @@ + + + TODO: beggathon + + diff --git a/src/popup/panels/VideoPanel.vue b/src/popup/panels/VideoPanel.vue new file mode 100644 index 0000000..8d00ebf --- /dev/null +++ b/src/popup/panels/VideoPanel.vue @@ -0,0 +1,133 @@ + + + + Cropping mode: + + + + + + + + + + Zooming and panning + + + + + + Zoom: 100% + + + reset + + + + + + Pan with mouse + + + + + + Stretching mode: + + + + + + + + + + Video alignment: + + + + + + + + + + Multi-command actions: + + + + + + + + + + + + + + diff --git a/src/popup/popup.js b/src/popup/popup.js index 939e105..b3688db 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -7,7 +7,5 @@ import App from './App' /* eslint-disable no-new */ new Vue({ el: '#app', - store, - render: h => h(App) })
Hello world!