From 4676de3303f1213dd91e6f515c9633e364e3e6d7 Mon Sep 17 00:00:00 2001 From: Lcode Date: Sun, 1 May 2022 15:41:24 +0800 Subject: [PATCH 1/2] add location options --- inject.js | 13 +++++++++++-- options.html | 5 +++++ options.js | 11 +++++++++-- shadow.css | 2 -- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/inject.js b/inject.js index 79f4e583..5174f9ef 100644 --- a/inject.js +++ b/inject.js @@ -12,6 +12,8 @@ var tc = { audioBoolean: false, // default: false startHidden: false, // default: false controllerOpacity: 0.3, // default: 0.3 + controllerLocationX: 0, // default: 0 + controllerLocationY: 0, // default: 0 keyBindings: [], blacklist: `\ www.instagram.com @@ -116,6 +118,8 @@ chrome.storage.sync.get(tc.settings, function (storage) { startHidden: tc.settings.startHidden, enabled: tc.settings.enabled, controllerOpacity: tc.settings.controllerOpacity, + controllerLocationX: tc.settings.controllerLocationX, + controllerLocationY: tc.settings.controllerLocationY, blacklist: tc.settings.blacklist.replace(regStrip, "") }); } @@ -127,6 +131,8 @@ chrome.storage.sync.get(tc.settings, function (storage) { tc.settings.enabled = Boolean(storage.enabled); tc.settings.startHidden = Boolean(storage.startHidden); tc.settings.controllerOpacity = Number(storage.controllerOpacity); + tc.settings.controllerLocationX = Number(storage.controllerLocationX); + tc.settings.controllerLocationY = Number(storage.controllerLocationY); tc.settings.blacklist = String(storage.blacklist); // ensure that there is a "display" binding (for upgrades from versions that had it as a separate binding) @@ -273,8 +279,11 @@ function defineVideoController() { log("initializeControls Begin", 5); const document = this.video.ownerDocument; const speed = this.video.playbackRate.toFixed(2); - var top = Math.max(this.video.offsetTop, 0) + "px", - left = Math.max(this.video.offsetLeft, 0) + "px"; + var curTransform = new WebKitCSSMatrix(window.getComputedStyle(this.video).webkitTransform); + var videoLeft = this.video.offsetLeft + curTransform.m41; //real offset left + var videoTop = this.video.offsetTop + curTransform.m42; //real offset top + var top = (Math.max(videoTop, 0)+tc.settings.controllerLocationY) + "px", + left = (Math.max(videoLeft, 0)+tc.settings.controllerLocationX) + "px"; log("Speed variable set to: " + speed, 5); diff --git a/options.html b/options.html index 242c326f..a8a39583 100644 --- a/options.html +++ b/options.html @@ -160,6 +160,11 @@

Other

+
+ + Left: + Top: +