From 9c3ca3744b5532db76aa32d8e313d902310cde41 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Mon, 31 Dec 2018 01:03:07 +0100 Subject: [PATCH] Reorganized stuff for content script & get it working (preliminary; performance issues on YT) --- .../enums/extension-mode.js} | 7 +- src/ext/conf/BrowserDetect.js | 36 ++-- src/ext/{modules => lib}/ActionHandler.js | 1 + src/ext/{modules => lib}/Interface.js | 0 src/ext/lib/KeyboardShortcutParser.js | 4 +- src/ext/lib/Settings.js | 4 +- src/ext/lib/UiFactory.js | 0 .../ar-detect/ArDetector.js} | 178 +++++++++--------- .../{modules => lib/ar-detect}/DebugCanvas.js | 2 +- src/ext/lib/{ => ar-detect}/GuardLine.js | 4 + .../{ => ar-detect/edge-detect}/EdgeDetect.js | 31 ++- .../enums/EdgeDetectPrimaryDirectionEnum.js | 6 + .../enums/EdgeDetectQualityEnum.js | 6 + .../edge-detect/enums/EdgeStatusEnum.js | 6 + .../{modules => lib/video-data}/PageInfo.js | 10 +- src/ext/lib/{ => video-data}/PlayerData.js | 4 + src/ext/lib/{ => video-data}/VideoData.js | 9 +- src/ext/lib/video-data/enums/RescanReason.js | 7 + .../video-transform}/Resizer.js | 12 +- .../video-transform}/Scaler.js | 6 +- .../video-transform}/Stretcher.js | 7 +- .../{modules => lib/video-transform}/Zoom.js | 11 +- src/ext/uw.js | 8 + src/manifest.json | 33 +--- 24 files changed, 215 insertions(+), 177 deletions(-) rename src/{ext/lib/enums.js => common/enums/extension-mode.js} (53%) rename src/ext/{modules => lib}/ActionHandler.js (99%) rename src/ext/{modules => lib}/Interface.js (100%) delete mode 100644 src/ext/lib/UiFactory.js rename src/ext/{modules/ArDetect.js => lib/ar-detect/ArDetector.js} (87%) rename src/ext/{modules => lib/ar-detect}/DebugCanvas.js (98%) rename src/ext/lib/{ => ar-detect}/GuardLine.js (99%) rename src/ext/lib/{ => ar-detect/edge-detect}/EdgeDetect.js (97%) create mode 100644 src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectPrimaryDirectionEnum.js create mode 100644 src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectQualityEnum.js create mode 100644 src/ext/lib/ar-detect/edge-detect/enums/EdgeStatusEnum.js rename src/ext/{modules => lib/video-data}/PageInfo.js (98%) rename src/ext/lib/{ => video-data}/PlayerData.js (98%) rename src/ext/lib/{ => video-data}/VideoData.js (95%) create mode 100644 src/ext/lib/video-data/enums/RescanReason.js rename src/ext/{modules => lib/video-transform}/Resizer.js (97%) rename src/ext/{modules => lib/video-transform}/Scaler.js (98%) rename src/ext/{modules => lib/video-transform}/Stretcher.js (98%) rename src/ext/{modules => lib/video-transform}/Zoom.js (92%) diff --git a/src/ext/lib/enums.js b/src/common/enums/extension-mode.js similarity index 53% rename from src/ext/lib/enums.js rename to src/common/enums/extension-mode.js index ef46612..7685785 100644 --- a/src/ext/lib/enums.js +++ b/src/common/enums/extension-mode.js @@ -6,9 +6,4 @@ var ExtensionMode = Object.freeze({ Full: 2 }); -var StretchMode = Object.freeze({ - NO_STRETCH: 0, - BASIC: 1, - HYBRID: 2, - CONDITIONAL: 3 -}); +export default ExtensionMode; \ No newline at end of file diff --git a/src/ext/conf/BrowserDetect.js b/src/ext/conf/BrowserDetect.js index 8b68be0..1e3c8ce 100644 --- a/src/ext/conf/BrowserDetect.js +++ b/src/ext/conf/BrowserDetect.js @@ -5,27 +5,27 @@ var _bd_isFirefox = true; var _bd_isChrome = false; var _bd_isEdge = false; // we'll see if FF -// try{ -// // todo: find something that works in firefox but not in edge (or vice-versa) -// // note that this function returns a promise! and is broken for some reason -// var browserinfo = browser.runtime.getBrowserInfo(); +try{ + // todo: find something that works in firefox but not in edge (or vice-versa) + // note that this function returns a promise! and is broken for some reason + var browserinfo = browser.runtime.getBrowserInfo(); -// // we don't need to actually check because only firefox supports that. -// // if we're not on firefox, the above call will probably throw an exception anyway. -// // if browsers other than firefox start supporting that, well ... we'll also need to actually await for promise -// // that getBrowserInfo() returns to resolve. + // we don't need to actually check because only firefox supports that. + // if we're not on firefox, the above call will probably throw an exception anyway. + // if browsers other than firefox start supporting that, well ... we'll also need to actually await for promise + // that getBrowserInfo() returns to resolve. -// // if (Browser.name.toLowerCase().indexOf(firefox) !== -1 || Browser.vendor.toLowerCase().indexOf(mozilla) !== -1) { -// _bd_isFirefox = true; -// _bd_isEdge = false; -// // } + // if (Browser.name.toLowerCase().indexOf(firefox) !== -1 || Browser.vendor.toLowerCase().indexOf(mozilla) !== -1) { + _bd_isFirefox = true; + _bd_isEdge = false; + // } -// } -// catch (e) { -// if(Debug.debug) { -// console.info("[BrowserDetect] browser.runtime.getBrowserInfo() probably failed. This means we're probably not using firefox.", e) -// } -// }; +} +catch (e) { + if(Debug.debug) { + console.info("[BrowserDetect] browser.runtime.getBrowserInfo() probably failed. This means we're probably not using firefox.", e) + } +}; try { if(browser === undefined){ // This is a good sign we're in chrome or chromium-based browsers diff --git a/src/ext/modules/ActionHandler.js b/src/ext/lib/ActionHandler.js similarity index 99% rename from src/ext/modules/ActionHandler.js rename to src/ext/lib/ActionHandler.js index 24329c8..cb7b3f6 100644 --- a/src/ext/modules/ActionHandler.js +++ b/src/ext/lib/ActionHandler.js @@ -1,4 +1,5 @@ import Debug from '../conf/Debug'; +import PlayerData from './video-data/PlayerData' class ActionHandler { diff --git a/src/ext/modules/Interface.js b/src/ext/lib/Interface.js similarity index 100% rename from src/ext/modules/Interface.js rename to src/ext/lib/Interface.js diff --git a/src/ext/lib/KeyboardShortcutParser.js b/src/ext/lib/KeyboardShortcutParser.js index b5c70cd..a2c946b 100644 --- a/src/ext/lib/KeyboardShortcutParser.js +++ b/src/ext/lib/KeyboardShortcutParser.js @@ -18,4 +18,6 @@ class KeyboardShortcutParser { return shortcutCombo; } -} \ No newline at end of file +} + +export default KeyboardShortcutParser; diff --git a/src/ext/lib/Settings.js b/src/ext/lib/Settings.js index 1f93497..052929e 100644 --- a/src/ext/lib/Settings.js +++ b/src/ext/lib/Settings.js @@ -1,7 +1,7 @@ import Debug from '../conf/Debug'; import currentBrowser from '../conf/BrowserDetect'; import ExtensionConf from '../conf/ExtensionConf'; - +import ExtensionMode from '../../common/enums/extension-mode'; class Settings { @@ -380,4 +380,4 @@ class Settings { } } -export default Settings; \ No newline at end of file +export default Settings; diff --git a/src/ext/lib/UiFactory.js b/src/ext/lib/UiFactory.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/ext/modules/ArDetect.js b/src/ext/lib/ar-detect/ArDetector.js similarity index 87% rename from src/ext/modules/ArDetect.js rename to src/ext/lib/ar-detect/ArDetector.js index 414cc8e..9a413dc 100644 --- a/src/ext/modules/ArDetect.js +++ b/src/ext/lib/ar-detect/ArDetector.js @@ -1,3 +1,11 @@ +import Debug from '../../conf/Debug'; +import EdgeDetect from './edge-detect/EdgeDetect'; +import EdgeStatus from './edge-detect/enums/EdgeStatusEnum'; +import EdgeDetectPrimaryDirection from './edge-detect/enums/EdgeDetectPrimaryDirectionEnum'; +import EdgeDetectQuality from './edge-detect/enums/EdgeDetectQualityEnum'; +import GuardLine from './GuardLine'; +import DebugCanvas from './DebugCanvas'; + class ArDetector { constructor(videoData){ @@ -34,7 +42,7 @@ class ArDetector { if(Debug.debug || Debug.init) { console.log(`[ArDetect::destroy] `) } - this.debugCanvas.destroy(); + // this.debugCanvas.destroy(); this.stop(); } @@ -42,7 +50,7 @@ class ArDetector { this.guardLine = new GuardLine(this); this.edgeDetector = new EdgeDetect(this); - this.debugCanvas = new DebugCanvas(this); + // this.debugCanvas = new DebugCanvas(this); if(Debug.debug || Debug.init) { console.log("[ArDetect::setup] Starting autodetection setup. arid:", this.arid); @@ -169,7 +177,7 @@ class ArDetector { } if(Debug.debugCanvas.enabled){ - this.debugCanvas.init({width: cwidth, height: cheight}); + // this.debugCanvas.init({width: cwidth, height: cheight}); // DebugCanvas.draw("test marker","test","rect", {x:5, y:5}, {width: 5, height: 5}); } @@ -276,7 +284,7 @@ class ArDetector { postFrameCheck(){ if(Debug.debugCanvas.enabled){ - this.debugCanvas.update(); + // this.debugCanvas.update(); } } @@ -520,7 +528,7 @@ class ArDetector { var image = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height).data; if(Debug.debugCanvas.enabled){ - this.debugCanvas.setBuffer(image); + // this.debugCanvas.setBuffer(image); } //#region black level detection @@ -709,7 +717,7 @@ class ArDetector { } // console.log("SAMPLES:", blackbarSamples, "candidates:", edgeCandidates, "post:", edgePost,"\n\nblack level:", this.blackLevel, "tresh:", this.blackLevel + this.settings.active.arDetect.blackbarTreshold); - if(edgePost.status == "ar_known"){ + if(edgePost.status == EdgeStatus.AR_KNOWN){ // zaznali smo rob — vendar pa moramo pred obdelavo še preveriti, ali ni "rob" slučajno besedilo. Če smo kot rob pofočkali // besedilo, potem to ni veljaven rob. Razmerja stranic se zato ne bomo pipali. @@ -789,97 +797,95 @@ class ArDetector { } } -if(Debug.debug) - console.log("Loading: ArDetect"); var _ard_console_stop = "background: #000; color: #f41"; var _ard_console_start = "background: #000; color: #00c399"; +// var textLineTest = function(image, row){ +// // preverimo, če vrstica vsebuje besedilo na črnem ozadju. Če ob pregledu vrstice naletimo na veliko sprememb +// // iz črnega v ne-črno, potem obstaja možnost, da gledamo besedilo. Prisotnost take vrstice je lahko znak, da +// // zaznano razmerje stranic ni veljavno +// // +// // vrne 'true' če zazna text, 'false' drugače. +// // +// // +// // check if line contains any text. If line scan reveals a lot of changes from black to non-black there's a +// // chance we're looking at text on a black background. If we detect text near what we think is an edge of the +// // video, there's a good chance we're about to incorrectly adjust the aspect ratio. +// // +// // returns 'true' if text is detected, 'false' otherwise -var textLineTest = function(image, row){ - // preverimo, če vrstica vsebuje besedilo na črnem ozadju. Če ob pregledu vrstice naletimo na veliko sprememb - // iz črnega v ne-črno, potem obstaja možnost, da gledamo besedilo. Prisotnost take vrstice je lahko znak, da - // zaznano razmerje stranic ni veljavno - // - // vrne 'true' če zazna text, 'false' drugače. - // - // - // check if line contains any text. If line scan reveals a lot of changes from black to non-black there's a - // chance we're looking at text on a black background. If we detect text near what we think is an edge of the - // video, there's a good chance we're about to incorrectly adjust the aspect ratio. - // - // returns 'true' if text is detected, 'false' otherwise +// var blackbarTreshold = this.blackLevel + this.settings.active.arDetect.blackbarTreshold; +// var nontextTreshold = this.canvas.width * this.settings.active.arDetect.textLineTest.nonTextPulse; - var blackbarTreshold = this.blackLevel + this.settings.active.arDetect.blackbarTreshold; - var nontextTreshold = this.canvas.width * this.settings.active.arDetect.textLineTest.nonTextPulse; +// var rowStart = (row * this.canvas.width) << 2; +// var rowEnd = rowStart + (this.canvas.width << 2); - var rowStart = (row * this.canvas.width) << 2; - var rowEnd = rowStart + (this.canvas.width << 2); +// var pulse = false; +// var currentPulseLength = 0, pulseCount = 0; +// var pulses = []; +// var longestBlack = 0; - var pulse = false; - var currentPulseLength = 0, pulseCount = 0; - var pulses = []; - var longestBlack = 0; - - // preglejmo vrstico - // analyse the row - for(var i = rowStart; i < rowEnd; i+= 4){ - if(pulse){ - if(image[i] < blackbarTreshold || image[i+1] < blackbarTreshold || image[i+2] < blackbarTreshold){ - // pulses.push(currentPulseLength); - pulseCount++; - pulse = false; - currentPulseLength = 0; - } - else{ - currentPulseLength++; +// // preglejmo vrstico +// // analyse the row +// for(var i = rowStart; i < rowEnd; i+= 4){ +// if(pulse){ +// if(image[i] < blackbarTreshold || image[i+1] < blackbarTreshold || image[i+2] < blackbarTreshold){ +// // pulses.push(currentPulseLength); +// pulseCount++; +// pulse = false; +// currentPulseLength = 0; +// } +// else{ +// currentPulseLength++; - // če najdemo dovolj dolgo zaporedje ne-črnih točk, potem vrnemo 'false' — dobili smo legitimen rob - // if we find long enough uninterrupted line of non-black point, we fail the test. We found a legit edge. - if(currentPulseLength > nontextTreshold){ - return false; - } - } - } - else{ - if(image[i] > blackbarTreshold || image[i+1] > blackbarTreshold || image[i+2] > blackbarTreshold){ - if(currentPulseLength > longestBlack){ - longestBlack = currentPulseLength; - } - pulse = true; - currentPulseLength = 0; - } - else{ - currentPulseLength++; - } - } - } - if(pulse){ - pulseCount++; - // pulses.push(currentPulseLength); - } +// // če najdemo dovolj dolgo zaporedje ne-črnih točk, potem vrnemo 'false' — dobili smo legitimen rob +// // if we find long enough uninterrupted line of non-black point, we fail the test. We found a legit edge. +// if(currentPulseLength > nontextTreshold){ +// return false; +// } +// } +// } +// else{ +// if(image[i] > blackbarTreshold || image[i+1] > blackbarTreshold || image[i+2] > blackbarTreshold){ +// if(currentPulseLength > longestBlack){ +// longestBlack = currentPulseLength; +// } +// pulse = true; +// currentPulseLength = 0; +// } +// else{ +// currentPulseLength++; +// } +// } +// } +// if(pulse){ +// pulseCount++; +// // pulses.push(currentPulseLength); +// } - // pregledamo rezultate: - // analyse the results - // console.log("pulse test:\n\npulses:", pulseCount, "longest black:", longestBlack); +// // pregledamo rezultate: +// // analyse the results +// // console.log("pulse test:\n\npulses:", pulseCount, "longest black:", longestBlack); - // če smo zaznali dovolj pulzov, potem vrnemo res - // if we detected enough pulses, we return true - if(pulseCount > this.settings.active.arDetect.textLineTest.pulsesToConfirm){ - return true; - } +// // če smo zaznali dovolj pulzov, potem vrnemo res +// // if we detected enough pulses, we return true +// if(pulseCount > this.settings.active.arDetect.textLineTest.pulsesToConfirm){ +// return true; +// } - // če je najdaljša neprekinjena črta črnih pikslov širša od polovice širine je merilo za zaznavanje - // besedila rahlo milejše - // if the longest uninterrupted line of black pixels is wider than half the width, we use a more - // forgiving standard for determining if we found text - if( longestBlack > (this.canvas.width >> 1) && - pulseCount > this.settings.active.arDetect.textLineTest.pulsesToConfirmIfHalfBlack ){ - return true; - } +// // če je najdaljša neprekinjena črta črnih pikslov širša od polovice širine je merilo za zaznavanje +// // besedila rahlo milejše +// // if the longest uninterrupted line of black pixels is wider than half the width, we use a more +// // forgiving standard for determining if we found text +// if( longestBlack > (this.canvas.width >> 1) && +// pulseCount > this.settings.active.arDetect.textLineTest.pulsesToConfirmIfHalfBlack ){ +// return true; +// } - // če pridemo do sem, potem besedilo ni bilo zaznano - // if we're here, no text was detected - return false; -} +// // če pridemo do sem, potem besedilo ni bilo zaznano +// // if we're here, no text was detected +// return false; +// } +export default ArDetector; diff --git a/src/ext/modules/DebugCanvas.js b/src/ext/lib/ar-detect/DebugCanvas.js similarity index 98% rename from src/ext/modules/DebugCanvas.js rename to src/ext/lib/ar-detect/DebugCanvas.js index 8e611a0..fbad560 100644 --- a/src/ext/modules/DebugCanvas.js +++ b/src/ext/lib/ar-detect/DebugCanvas.js @@ -116,7 +116,7 @@ class DebugCanvas { } DebugCanvasClasses = { - VIOLATION: {color: '#ff0000', colorRgb: [255, 00, 0], text: 'violation (general)'}, + VIOLATION: {color: '#ff0000', colorRgb: [255, 0, 0], text: 'violation (general)'}, WARN: {color: '#d0d039', colorRgb: [208, 208, 57], text: 'lesser violation (general)'}, GUARDLINE_BLACKBAR: {color: '#3333FF', colorRgb: [51, 51, 255], text: 'guardline/blackbar (expected value)'}, GUARDLINE_IMAGE: {color: '#000088', colorRgb: [0, 0, 136], text: 'guardline/image (expected value)'}, diff --git a/src/ext/lib/GuardLine.js b/src/ext/lib/ar-detect/GuardLine.js similarity index 99% rename from src/ext/lib/GuardLine.js rename to src/ext/lib/ar-detect/GuardLine.js index 49f87e5..48f35ee 100644 --- a/src/ext/lib/GuardLine.js +++ b/src/ext/lib/ar-detect/GuardLine.js @@ -1,3 +1,5 @@ +import Debug from '../../conf/Debug'; + class GuardLine { // ardConf — reference to ArDetector that has current GuardLine instance @@ -302,3 +304,5 @@ class GuardLine { return false; } } + +export default GuardLine; diff --git a/src/ext/lib/EdgeDetect.js b/src/ext/lib/ar-detect/edge-detect/EdgeDetect.js similarity index 97% rename from src/ext/lib/EdgeDetect.js rename to src/ext/lib/ar-detect/edge-detect/EdgeDetect.js index 1bec891..4fae9cc 100644 --- a/src/ext/lib/EdgeDetect.js +++ b/src/ext/lib/ar-detect/edge-detect/EdgeDetect.js @@ -1,12 +1,7 @@ -var EdgeDetectPrimaryDirection = { - VERTICAL: 0, - HORIZONTAL: 1 -} - -var EdgeDetectQuality = { - FAST: 0, - IMPROVED: 1 -} +import Debug from '../../../conf/Debug'; +import EdgeStatus from './enums/EdgeStatusEnum'; +import EdgeDetectQuality from './enums/EdgeDetectQualityEnum'; +import EdgeDetectPrimaryDirection from './enums/EdgeDetectPrimaryDirectionEnum'; class EdgeDetect{ @@ -40,7 +35,7 @@ class EdgeDetect{ // } } else { - bars = this.pillarTest(image) ? {status: 'ar_known'} : {status: 'ar_unknown'}; + bars = this.pillarTest(image) ? {status: EdgeStatus.AR_KNOWN} : {status: EdgeStatus.AR_UNKNOWN}; } return bars; @@ -290,7 +285,7 @@ class EdgeDetect{ edgesTop[0].distance : edgesBottom[0].distance; return { - status: "ar_known", + status: EdgeStatus.AR_KNOWN, blackbarWidth: blackbarWidth, guardLineTop: edgesTop[0].distance, guardLineBottom: edgesBottom[0].absolute, @@ -321,7 +316,7 @@ class EdgeDetect{ edgesTop[i].distance : edgesBottom[0].distance; return { - status: "ar_known", + status: EdgeStatus.AR_KNOWN, blackbarWidth: blackbarWidth, guardLineTop: edgesTop[i].distance, guardLineBottom: edgesBottom[0].absolute, @@ -349,7 +344,7 @@ class EdgeDetect{ edgesBottom[i].distance : edgesTop[0].distance; return { - status: "ar_known", + status: EdgeStatus.AR_KNOWN, blackbarWidth: blackbarWidth, guardLineTop: edgesTop[0].distance, guardLineBottom: edgesBottom[0].absolute, @@ -374,7 +369,7 @@ class EdgeDetect{ for(var edge of edgesBottom){ if(edge.count >= edgeDetectionTreshold) return { - status: "ar_known", + status: EdgeStatus.AR_KNOWN, blackbarWidth: edge.distance, guardLineTop: null, guardLineBottom: edge.bottom, @@ -388,7 +383,7 @@ class EdgeDetect{ for(var edge of edgesTop){ if(edge.count >= edgeDetectionTreshold) return { - status: "ar_known", + status: EdgeStatus.AR_KNOWN, blackbarWidth: edge.distance, guardLineTop: edge.top, guardLineBottom: null, @@ -401,7 +396,7 @@ class EdgeDetect{ } // če pridemo do sem, nam ni uspelo nič. Razmerje stranic ni znano // if we reach this bit, we have failed in determining aspect ratio. It remains unknown. - return {status: "ar_unknown"} + return {status: EdgeStatus.AR_UNKNOWN} } pillarTest(image){ @@ -646,4 +641,6 @@ class EdgeDetect{ } } -} \ No newline at end of file +} + +export default EdgeDetect; diff --git a/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectPrimaryDirectionEnum.js b/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectPrimaryDirectionEnum.js new file mode 100644 index 0000000..c2b10fa --- /dev/null +++ b/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectPrimaryDirectionEnum.js @@ -0,0 +1,6 @@ +var EdgeDetectPrimaryDirection = Object.freeze({ + VERTICAL: 0, + HORIZONTAL: 1 +}); + +export default EdgeDetectPrimaryDirection; diff --git a/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectQualityEnum.js b/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectQualityEnum.js new file mode 100644 index 0000000..f1247f6 --- /dev/null +++ b/src/ext/lib/ar-detect/edge-detect/enums/EdgeDetectQualityEnum.js @@ -0,0 +1,6 @@ +var EdgeDetectQuality = Object.freeze({ + FAST: 0, + IMPROVED: 1 +}); + +export default EdgeDetectQuality; diff --git a/src/ext/lib/ar-detect/edge-detect/enums/EdgeStatusEnum.js b/src/ext/lib/ar-detect/edge-detect/enums/EdgeStatusEnum.js new file mode 100644 index 0000000..65946cf --- /dev/null +++ b/src/ext/lib/ar-detect/edge-detect/enums/EdgeStatusEnum.js @@ -0,0 +1,6 @@ +var EdgeStatus = Object.freeze({ + AR_UNKNOWN: 0, + AR_KNOWN: 1, +}); + +export default EdgeStatus; diff --git a/src/ext/modules/PageInfo.js b/src/ext/lib/video-data/PageInfo.js similarity index 98% rename from src/ext/modules/PageInfo.js rename to src/ext/lib/video-data/PageInfo.js index 39871fd..731bd93 100644 --- a/src/ext/modules/PageInfo.js +++ b/src/ext/lib/video-data/PageInfo.js @@ -1,3 +1,7 @@ +import Debug from '../../conf/Debug'; +import VideoData from './VideoData'; +import RescanReason from './enums/RescanReason'; + if(Debug.debug) console.log("Loading: PageInfo.js"); @@ -444,8 +448,4 @@ class PageInfo { } } -var RescanReason = { - PERIODIC: 0, - URL_CHANGE: 1, - MANUAL: 2 -} \ No newline at end of file +export default PageInfo; diff --git a/src/ext/lib/PlayerData.js b/src/ext/lib/video-data/PlayerData.js similarity index 98% rename from src/ext/lib/PlayerData.js rename to src/ext/lib/video-data/PlayerData.js index e21bc07..9806f8c 100644 --- a/src/ext/lib/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -1,3 +1,6 @@ +import Debug from '../../conf/Debug'; +import ExtensionMode from '../../../common/enums/extension-mode' + if(Debug.debug) console.log("Loading: PlayerData.js"); @@ -381,3 +384,4 @@ class PlayerData { } } +export default PlayerData; diff --git a/src/ext/lib/VideoData.js b/src/ext/lib/video-data/VideoData.js similarity index 95% rename from src/ext/lib/VideoData.js rename to src/ext/lib/video-data/VideoData.js index 547533a..09485bb 100644 --- a/src/ext/lib/VideoData.js +++ b/src/ext/lib/video-data/VideoData.js @@ -1,3 +1,8 @@ +import Debug from '../../conf/Debug'; +import PlayerData from './PlayerData'; +import Resizer from '../video-transform/Resizer'; +import ArDetector from '../ar-detect/ArDetector'; + class VideoData { constructor(video, settings, pageInfo){ @@ -206,4 +211,6 @@ class VideoData { return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended; } -} \ No newline at end of file +} + +export default VideoData; diff --git a/src/ext/lib/video-data/enums/RescanReason.js b/src/ext/lib/video-data/enums/RescanReason.js new file mode 100644 index 0000000..03e170b --- /dev/null +++ b/src/ext/lib/video-data/enums/RescanReason.js @@ -0,0 +1,7 @@ +var RescanReason = Object.freeze({ + PERIODIC: 0, + URL_CHANGE: 1, + MANUAL: 2 +}); + +export default RescanReason; diff --git a/src/ext/modules/Resizer.js b/src/ext/lib/video-transform/Resizer.js similarity index 97% rename from src/ext/modules/Resizer.js rename to src/ext/lib/video-transform/Resizer.js index 5a2dc3f..2f57485 100644 --- a/src/ext/modules/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -1,7 +1,15 @@ +import Debug from '../../conf/Debug'; +import Scaler from './Scaler'; +import Stretcher from './Stretcher'; +import Zoom from './Zoom'; +import PlayerData from '../video-data/PlayerData'; +import ExtensionMode from '../../../common/enums/extension-mode'; +import StretchMode from '../../../common/enums/stretch-mode'; + if(Debug.debug) console.log("Loading: Resizer.js"); - class Resizer { +class Resizer { constructor(videoData) { this.conf = videoData; @@ -491,3 +499,5 @@ if(Debug.debug) } } } + +export default Resizer; diff --git a/src/ext/modules/Scaler.js b/src/ext/lib/video-transform/Scaler.js similarity index 98% rename from src/ext/modules/Scaler.js rename to src/ext/lib/video-transform/Scaler.js index c940e3b..abc11fb 100644 --- a/src/ext/modules/Scaler.js +++ b/src/ext/lib/video-transform/Scaler.js @@ -1,3 +1,5 @@ +import Debug from '../../conf/Debug'; + // računa velikost videa za približevanje/oddaljevanje // does video size calculations for zooming/cropping @@ -145,4 +147,6 @@ class Scaler { return videoDimensions; } -} \ No newline at end of file +} + +export default Scaler; diff --git a/src/ext/modules/Stretcher.js b/src/ext/lib/video-transform/Stretcher.js similarity index 98% rename from src/ext/modules/Stretcher.js rename to src/ext/lib/video-transform/Stretcher.js index 58b99fc..cd2434d 100644 --- a/src/ext/modules/Stretcher.js +++ b/src/ext/lib/video-transform/Stretcher.js @@ -1,9 +1,10 @@ +import Debug from '../../conf/Debug'; + // računa vrednosti za transform-scale (x, y) // transform: scale(x,y) se uporablja za raztegovanje videa, ne pa za približevanje // calculates values for transform scale(x, y) // transform: scale(x,y) is used for stretching, not zooming. - class Stretcher { // internal variables @@ -177,4 +178,6 @@ class Stretcher { return stretchFactors; } -} \ No newline at end of file +} + +export default Stretcher; diff --git a/src/ext/modules/Zoom.js b/src/ext/lib/video-transform/Zoom.js similarity index 92% rename from src/ext/modules/Zoom.js rename to src/ext/lib/video-transform/Zoom.js index 9ba5de4..2f82e67 100644 --- a/src/ext/modules/Zoom.js +++ b/src/ext/lib/video-transform/Zoom.js @@ -1,10 +1,9 @@ -// računa približevanje ter računa/popravlja odmike videa +import Debug from '../../conf/Debug'; +// računa približevanje ter računa/popravlja odmike videa +// calculates zooming and video offsets/panning class Zoom { - // internal variables - - // functions constructor(videoData) { this.scale = 1; @@ -59,4 +58,6 @@ class Zoom { stretchFactors.xFactor *= this.scale; stretchFactors.yFactor *= this.scale; } -} \ No newline at end of file +} + +export default Zoom; diff --git a/src/ext/uw.js b/src/ext/uw.js index c09f6c4..6a9d9ae 100644 --- a/src/ext/uw.js +++ b/src/ext/uw.js @@ -1,3 +1,11 @@ +import Debug from './conf/Debug'; +import BrowserDetect from './conf/BrowserDetect'; +import ExtensionMode from '../common/enums/extension-mode' +import Settings from './lib/Settings'; +import ActionHandler from './lib/ActionHandler'; +import CommsClient from './lib/comms/CommsClient'; +import PageInfo from './lib/video-data/PageInfo'; + if(Debug.debug){ console.log("\n\n\n\n\n\n ——— Sᴛλʀᴛɪɴɢ Uʟᴛʀᴀᴡɪᴅɪꜰʏ ———\n << ʟᴏᴀᴅɪɴɢ ᴍᴀɪɴ ꜰɪʟᴇ >>\n\n\n\n"); try { diff --git a/src/manifest.json b/src/manifest.json index af6abd5..40a6c6c 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -19,37 +19,8 @@ "content_scripts": [{ "matches": ["*://*/*"], - "js": [ - "js/conf/Debug.js", - "js/lib/enums.js", - - "js/lib/BrowserDetect.js", - "js/conf/ExtensionConf.js", - - "js/lib/ObjectCopy.js", - "js/lib/Settings.js", - - "js/lib/Comms.js", - - "js/lib/EdgeDetect.js", - "js/lib/GuardLine.js", - - - - "js/modules/PageInfo.js", - "js/modules/DebugCanvas.js", - "js/modules/ArDetect.js", - "js/modules/Zoom.js", - "js/modules/Scaler.js", - "js/modules/Stretcher.js", - - "js/modules/Resizer.js", - "js/lib/PlayerData.js", - "js/lib/VideoData.js", - - "js/modules/ActionHandler.js", - - "js/uw.js" + "js": [ + "ext/uw.js" ], "all_frames": true }],