rewrite finished to the point where extension doesn't outright crash. Nothing works, though.
This commit is contained in:
parent
0ac051d5d5
commit
3686341677
@ -1,6 +1,6 @@
|
||||
// Set prod to true when releasing
|
||||
_prod = true;
|
||||
// _prod = false;
|
||||
// _prod = true;
|
||||
_prod = false;
|
||||
|
||||
Debug = {
|
||||
debug: true,
|
||||
|
@ -27,7 +27,7 @@ class EdgeDetect{
|
||||
}
|
||||
|
||||
findBars(image, sampleCols, direction = EdgeDetectPrimaryDirection.VERTICAL, quality = EdgeDetectQuality.IMPROVED, guardLineOut){
|
||||
var fastCandidates, edgeCandidates, bars,
|
||||
var fastCandidates, edgeCandidates, bars;
|
||||
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
||||
fastCandidates = this.findCandidates(image, sampleCols, guardLine);
|
||||
|
||||
@ -230,7 +230,7 @@ class EdgeDetect{
|
||||
};
|
||||
}
|
||||
|
||||
edgePostprocess = function(edges){
|
||||
edgePostprocess(edges){
|
||||
var edgesTop = [];
|
||||
var edgesBottom = [];
|
||||
var alignMargin = this.conf.context.height * ExtensionConf.arDetect.allowedMisaligned;
|
||||
|
@ -99,7 +99,7 @@ class PlayerData {
|
||||
return;
|
||||
}
|
||||
|
||||
var isFullScreen = PlayerData.isFullScreen();
|
||||
var isFullScreen = this.isFullScreen();
|
||||
|
||||
var trustCandidateAfterGrows = 2; // if candidate_width or candidate_height increases in either dimensions this many
|
||||
// times, we say we found our player. (This number ignores weird elements)
|
||||
|
@ -3,7 +3,7 @@ class VideoData {
|
||||
constructor(video){
|
||||
this.video = video;
|
||||
// todo: add ArDetect instance
|
||||
this.arDetector = new ArDetector(video);
|
||||
this.arDetector = new ArDetector(video); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting
|
||||
this.resizer = new Resizer(this);
|
||||
this.player = new PlayerData(this);
|
||||
|
||||
@ -27,5 +27,12 @@ class VideoData {
|
||||
this.resizer.setLastAr(lastAr);
|
||||
}
|
||||
|
||||
setAr(ar, lastAr){
|
||||
this.resizer.setAr(ar, lastAr);
|
||||
}
|
||||
|
||||
setStretchMode(stretchMode){
|
||||
this.resizer.setStretchMode(stretchMode);
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ class ArDetector {
|
||||
this.guardLine = new GuardLine(this);
|
||||
this.edgeDetector = new EdgeDetect(this);
|
||||
this.debugCanvas = new DebugCanvas(this);
|
||||
setup(ExtensionConf.arDetect.hSamples, ExtensionConf.arDetect.vSamples);
|
||||
this.setup(ExtensionConf.arDetect.hSamples, ExtensionConf.arDetect.vSamples);
|
||||
}
|
||||
|
||||
setup(cwidth, cheight){
|
||||
@ -226,7 +226,7 @@ class ArDetector {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
processAr = function(edges){
|
||||
processAr(edges){
|
||||
|
||||
if(Debug.debug && Debug.debugArDetect){
|
||||
console.log("[ArDetect::_ard_processAr] processing ar. sample width:", this.canvas.width, "; sample height:", this.canvas.height, "; edge top:", edges.top);
|
||||
|
@ -3,7 +3,7 @@ class DebugCanvas {
|
||||
this.conf = ardConf;
|
||||
}
|
||||
|
||||
init = async function(canvasSize, canvasPosition){
|
||||
init(canvasSize, canvasPosition) {
|
||||
console.log("initiating DebugCanvas")
|
||||
|
||||
var body = document.getElementsByTagName('body')[0];
|
||||
@ -34,12 +34,12 @@ class DebugCanvas {
|
||||
console.log("debug canvas is:", this.canvas, "context:", this.context)
|
||||
}
|
||||
|
||||
setBuffer = function(buffer) {
|
||||
setBuffer(buffer) {
|
||||
// this.imageBuffer = buffer.splice(0);
|
||||
this.imageBuffer = new Uint8ClampedArray(buffer);
|
||||
}
|
||||
|
||||
trace = function(arrayIndex, colorClass){
|
||||
trace(arrayIndex, colorClass) {
|
||||
this.imageBuffer[arrayIndex ] = colorClass.colorRgb[0];
|
||||
this.imageBuffer[arrayIndex+1] = colorClass.colorRgb[1];
|
||||
this.imageBuffer[arrayIndex+2] = colorClass.colorRgb[2];
|
||||
|
@ -6,19 +6,23 @@ class PageInfo {
|
||||
this.hasVideos = false;
|
||||
this.siteDisabled = false;
|
||||
this.videos = [];
|
||||
|
||||
|
||||
this.rescan();
|
||||
}
|
||||
|
||||
rescan(count){
|
||||
var vids = document.getElementsByTagName('video');
|
||||
|
||||
rescan(){
|
||||
var videos = document.getElementsByTagName('video');
|
||||
|
||||
if(!videos || videos.length == 0){
|
||||
if(!vids || vids.length == 0){
|
||||
this.hasVideos = false;
|
||||
return;
|
||||
}
|
||||
|
||||
debugger;
|
||||
|
||||
// add new videos
|
||||
for(video of videos){
|
||||
for(var video of vids){
|
||||
var existing = this.videos.find( (x) => {
|
||||
if (x == video.video)
|
||||
return x;
|
||||
@ -30,20 +34,30 @@ class PageInfo {
|
||||
if(existing){
|
||||
video.video = existing;
|
||||
} else {
|
||||
videos.push(
|
||||
this.videos.push(
|
||||
new VideoData(video)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initAr(){
|
||||
for(var vd in this.videos){
|
||||
vd.initAr();
|
||||
}
|
||||
}
|
||||
|
||||
var _pi_hasVideos = function(){
|
||||
// return true;
|
||||
var videos = document.getElementsByTagName("video");
|
||||
if(videos.length == 0)
|
||||
return false;
|
||||
setAr(ar){
|
||||
// TODO: find a way to only change aspect ratio for one video
|
||||
for(var vd in this.videos){
|
||||
vd.setAr(ar)
|
||||
}
|
||||
}
|
||||
|
||||
// if(videos[0].style.display == "none") // in this case ultrawidify doesn't even work
|
||||
// return false;
|
||||
setStretchMode(sm){
|
||||
for(var vd in this.videos){
|
||||
vd.setStretchMode(ar)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
if(Debug.debug)
|
||||
console.log("Loading: Resizer.js");
|
||||
|
||||
|
||||
|
||||
var StretchMode = {
|
||||
NO_STRETCH = 0,
|
||||
CONDITIONAL = 1,
|
||||
FULL = 2
|
||||
NO_STRETCH: 0,
|
||||
CONDITIONAL: 1,
|
||||
FULL: 2
|
||||
}
|
||||
|
||||
|
||||
|
96
js/uw.js
96
js/uw.js
@ -12,51 +12,23 @@ if(Debug.debug){
|
||||
}
|
||||
}
|
||||
|
||||
class VideoManager {
|
||||
|
||||
|
||||
refresh(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load all settings from localStorage:
|
||||
|
||||
async function main(){
|
||||
async function init(){
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] loading configuration ...");
|
||||
|
||||
// load settings
|
||||
var isSlave = true;
|
||||
await Settings.init(isSlave);
|
||||
var scpromise = SitesConf.init();
|
||||
var kbpromise = Keybinds.init();
|
||||
|
||||
// reset current css stuff in GlobalVars
|
||||
GlobalVars.correctedVideoDimensions.top = null;
|
||||
GlobalVars.correctedVideoDimensions.left = null;
|
||||
GlobalVars.correctedVideoDimensions.width = null;
|
||||
GlobalVars.correctedVideoDimensions.height = null;
|
||||
// za sporočilca poslušamo v vsakem primeru, tudi če je razširitev na spletnem mestu onemogočena
|
||||
// we listen for messages in any case, even if extension is disabled on current site.
|
||||
browser.runtime.onMessage.addListener(receiveMessage);
|
||||
|
||||
GlobalVars.currentCss = {top: null, left: null};
|
||||
|
||||
// počakamo, da so nastavitve naložene
|
||||
// wait for settings to load
|
||||
await scpromise;
|
||||
await kbpromise;
|
||||
|
||||
// globalVars: lastAr type = original
|
||||
GlobalVars.lastAr = {type: "original"};
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] configuration should be loaded now");
|
||||
// start autoar and setup everything
|
||||
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] | document is ready. Starting ar script ...");
|
||||
await SitesConf.init();
|
||||
// če je trenutno mesto onemogočeno, potem zaključimo na tem mestu
|
||||
// if current site is disabled, we quit here
|
||||
|
||||
if(! SitesConf.isEnabled(window.location.hostname)){
|
||||
if(Debug.debug)
|
||||
@ -65,35 +37,39 @@ async function main(){
|
||||
return;
|
||||
}
|
||||
|
||||
// if(SitesConf.isArEnabled(window.location.hostname)){
|
||||
|
||||
|
||||
await Keybinds.init();
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] configuration should be loaded now");
|
||||
|
||||
|
||||
// setup the extension
|
||||
setup();
|
||||
}
|
||||
|
||||
var pageInfo;
|
||||
|
||||
async function setup(){
|
||||
|
||||
pageInfo = new PageInfo();
|
||||
|
||||
if(Debug.debug){
|
||||
console.log("[uw.js::setup] pageInfo initialized. Here's the object:", pageInfo);
|
||||
}
|
||||
|
||||
// if(ExtensionConf.arDetect.mode == "blacklist"){
|
||||
// if(Debug.debug)
|
||||
// console.log("[uw::main] Aspect ratio detection is enabled. Starting ArDetect");
|
||||
// console.log("[uw::main] Aspect ratio detection is enabled (mode=",ExtensionConf.arDetect.mode,"). Starting ArDetect");
|
||||
// ArDetect.arSetup();
|
||||
// }
|
||||
// console.log("[uw::main] ExtensionConf:", ExtensionConf);
|
||||
// else{
|
||||
// if(Debug.debug)
|
||||
// console.log("[uw::main] Aspect ratio detection is disabled. Mode:", ExtensionConf.arDetect.mode);
|
||||
// }
|
||||
|
||||
if(ExtensionConf.arDetect.mode == "blacklist"){
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] Aspect ratio detection is enabled (mode=",ExtensionConf.arDetect.mode,"). Starting ArDetect");
|
||||
ArDetect.arSetup();
|
||||
}
|
||||
else{
|
||||
if(Debug.debug)
|
||||
console.log("[uw::main] Aspect ratio detection is disabled. Mode:", ExtensionConf.arDetect.mode);
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(receiveMessage);
|
||||
setInterval( ghettoOnChange, 100);
|
||||
setInterval( ghettoUrlWatcher, 500);
|
||||
|
||||
// ko se na ticevki zamenja video, console.log pravi da ultrawidify spremeni razmerje stranic. preglej element
|
||||
// in pogled na predvajalnik pravita, da se to ni zgodilo. Iz tega sledi, da nam ticevka povozi css, ki smo ga
|
||||
// vsilili. To super duper ni kul, zato uvedemo nekaj protiukrepov.
|
||||
//
|
||||
// when you change a video on youtube, console.log says that ultrawidify changes aspect ratio. inspect element
|
||||
// and a look at youtube player, on the other hand, say this didn't happen. It seems that youtube overrides our
|
||||
// css, and this is super duper uncool. Therefore, extra checks and measures.
|
||||
setInterval( Resizer.antiCssOverride, 200);
|
||||
|
||||
}
|
||||
|
||||
@ -272,5 +248,5 @@ function receiveMessage(message, sender, sendResponse) {
|
||||
|
||||
|
||||
// $(document).ready(function() {
|
||||
main();
|
||||
init();
|
||||
// });
|
||||
|
Loading…
Reference in New Issue
Block a user