diff --git a/.gitignore b/.gitignore index daf34ca..3a101a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ ultrawidify.zip +old/ diff --git a/js/conf/Debug.js b/js/conf/Debug.js index 037bdf8..34a1f4d 100644 --- a/js/conf/Debug.js +++ b/js/conf/Debug.js @@ -1,6 +1,7 @@ Debug = { debug: true, - debugArDetect: true + debugArDetect: true, + showArDetectCanvas: false } if(Debug.debug) diff --git a/js/conf/Keybinds.js b/js/conf/Keybinds.js index 59fe46b..76ec45e 100644 --- a/js/conf/Keybinds.js +++ b/js/conf/Keybinds.js @@ -62,12 +62,14 @@ var DEFAULT_KEYBINDINGS = { var _kbd_setup = function() { StorageManager.getopt("keybinds"); - } var _kbd_setup_stage2 = function(){ + // todo: dont do that + var KEYBINDS = DEFAULT_KEYBINDINGS; + if(Debug.debug || Debug.keyboard) console.log("uw::keydownSetup | starting keybord shortcut setup"); $(document).keydown(function (event) { // Tukaj ugotovimo, katero tipko smo pritisnili @@ -75,7 +77,7 @@ var _kbd_setup_stage2 = function(){ // Tipke upoštevamo samo, če smo v celozaslonskem načinu oz. če ne pišemo komentarja // v nasprotnem primeru ne naredimo nič. // We only take actions if we're in full screen or not writing a comment - if( !(inFullScreen || ( + if( !(FullScreenDetect.isFullScreen() || ( (document.activeElement.getAttribute("role") != "textbox") && (document.activeElement.getAttribute("type") != "text") ))){ @@ -95,7 +97,7 @@ var _kbd_setup_stage2 = function(){ }); sending.then( function(){}, function(){console.log("uw/keydown: there was an error while sending a message")} ); console.log("uw/keydown: test message sent! (probably)"); - return; +// return; } } @@ -124,23 +126,28 @@ var _kbd_setup_stage2 = function(){ console.log("uw::keydown | keys match. Taking action."); if(KEYBINDS[i].action == "char"){ - changeCSS("char", KEYBINDS[i].targetAR); + Status.arStrat = "fixed"; + Status["lastAr"] = KEYBINDS[i].targetAR; + Resizer.setAr(KEYBINDS[i].targetAR); return; } if(KEYBINDS[i].action == "autoar"){ - manual_autoar(); + Status.arStrat = "auto"; return; } - changeCSS("anything goes", KEYBINDS[i].action); +// changeCSS("anything goes", KEYBINDS[i].action); + Status.arStrat = KEYBINDS[i].action; + Resizer.legacyAr(KEYBINDS[i].action); return; } } } }); - document.addEventListener("mozfullscreenchange", function( event ) { - onFullScreenChange(); - inFullScreen = ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); - inFullScreen ? onFullscreenOn() : onFullscreenOff(); - }); +// document.addEventListener("mozfullscreenchange", function( event ) { +// onFullScreenChange(); +// inFullScreen = ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); +// inFullScreen ? onFullscreenOn() : onFullscreenOff(); +// }); } +_kbd_setup_stage2(); diff --git a/js/conf/Status.js b/js/conf/Status.js new file mode 100644 index 0000000..f3d1156 --- /dev/null +++ b/js/conf/Status.js @@ -0,0 +1,3 @@ +var Status = { + arStrat: "auto" +} diff --git a/js/dep/require.js b/js/dep/require.js deleted file mode 100644 index a3ca583..0000000 --- a/js/dep/require.js +++ /dev/null @@ -1,5 +0,0 @@ -/** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.3.5 Copyright jQuery Foundation and other contributors. - * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE - */ -var requirejs,require,define;!function(global,setTimeout){function commentReplace(e,t){return t||""}function isFunction(e){return"[object Function]"===ostring.call(e)}function isArray(e){return"[object Array]"===ostring.call(e)}function each(e,t){if(e){var i;for(i=0;i-1&&(!e[i]||!t(e[i],i,e));i-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var i;for(i in e)if(hasProp(e,i)&&t(e[i],i))break}function mixin(e,t,i,r){return t&&eachProp(t,function(t,n){!i&&hasProp(e,n)||(!r||"object"!=typeof t||!t||isArray(t)||isFunction(t)||t instanceof RegExp?e[n]=t:(e[n]||(e[n]={}),mixin(e[n],t,i,r)))}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,i,r){var n=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return n.requireType=e,n.requireModules=r,i&&(n.originalError=i),n}function newContext(e){function t(e){var t,i;for(t=0;t0&&(e.splice(t-1,2),t-=2)}}function i(e,i,r){var n,o,a,s,u,c,d,p,f,l,h=i&&i.split("/"),m=y.map,g=m&&m["*"];if(e&&(c=(e=e.split("/")).length-1,y.nodeIdCompat&&jsSuffixRegExp.test(e[c])&&(e[c]=e[c].replace(jsSuffixRegExp,"")),"."===e[0].charAt(0)&&h&&(e=h.slice(0,h.length-1).concat(e)),t(e),e=e.join("/")),r&&m&&(h||g)){e:for(a=(o=e.split("/")).length;a>0;a-=1){if(u=o.slice(0,a).join("/"),h)for(s=h.length;s>0;s-=1)if((n=getOwn(m,h.slice(0,s).join("/")))&&(n=getOwn(n,u))){d=n,p=a;break e}!f&&g&&getOwn(g,u)&&(f=getOwn(g,u),l=a)}!d&&f&&(d=f,p=l),d&&(o.splice(0,p,d),e=o.join("/"))}return getOwn(y.pkgs,e)||e}function r(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===q.contextName)return t.parentNode.removeChild(t),!0})}function n(e){var t=getOwn(y.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),q.require.undef(e),q.makeRequire(null,{skipMap:!0})([e]),!0}function o(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function a(e,t,r,n){var a,s,u,c,d=null,p=t?t.name:null,f=e,l=!0,h="";return e||(l=!1,e="_@r"+(T+=1)),c=o(e),d=c[0],e=c[1],d&&(d=i(d,p,n),s=getOwn(j,d)),e&&(d?h=r?e:s&&s.normalize?s.normalize(e,function(e){return i(e,p,n)}):-1===e.indexOf("!")?i(e,p,n):e:(d=(c=o(h=i(e,p,n)))[0],h=c[1],r=!0,a=q.nameToUrl(h))),u=!d||s||r?"":"_unnormalized"+(A+=1),{prefix:d,name:h,parentMap:t,unnormalized:!!u,url:a,originalName:f,isDefine:l,id:(d?d+"!"+h:h)+u}}function s(e){var t=e.id,i=getOwn(S,t);return i||(i=S[t]=new q.Module(e)),i}function u(e,t,i){var r=e.id,n=getOwn(S,r);!hasProp(j,r)||n&&!n.defineEmitComplete?(n=s(e)).error&&"error"===t?i(n.error):n.on(t,i):"defined"===t&&i(j[r])}function c(e,t){var i=e.requireModules,r=!1;t?t(e):(each(i,function(t){var i=getOwn(S,t);i&&(i.error=e,i.events.error&&(r=!0,i.emit("error",e)))}),r||req.onError(e))}function d(){globalDefQueue.length&&(each(globalDefQueue,function(e){var t=e[0];"string"==typeof t&&(q.defQueueMap[t]=!0),O.push(e)}),globalDefQueue=[])}function p(e){delete S[e],delete k[e]}function f(e,t,i){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,n){var o=r.id,a=getOwn(S,o);!a||e.depMatched[n]||i[o]||(getOwn(t,o)?(e.defineDep(n,j[o]),e.check()):f(a,t,i))}),i[r]=!0)}function l(){var e,t,i=1e3*y.waitSeconds,o=i&&q.startTime+i<(new Date).getTime(),a=[],s=[],u=!1,d=!0;if(!x){if(x=!0,eachProp(k,function(e){var i=e.map,c=i.id;if(e.enabled&&(i.isDefine||s.push(e),!e.error))if(!e.inited&&o)n(c)?(t=!0,u=!0):(a.push(c),r(c));else if(!e.inited&&e.fetched&&i.isDefine&&(u=!0,!i.prefix))return d=!1}),o&&a.length)return e=makeError("timeout","Load timeout for modules: "+a,null,a),e.contextName=q.contextName,c(e);d&&each(s,function(e){f(e,{},{})}),o&&!t||!u||!isBrowser&&!isWebWorker||w||(w=setTimeout(function(){w=0,l()},50)),x=!1}}function h(e){hasProp(j,e[0])||s(a(e[0],null,!0)).init(e[1],e[2])}function m(e,t,i,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(i,t,!1)}function g(e){var t=e.currentTarget||e.srcElement;return m(t,q.onScriptLoad,"load","onreadystatechange"),m(t,q.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function v(){var e;for(d();O.length;){if(null===(e=O.shift())[0])return c(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));h(e)}q.defQueueMap={}}var x,b,q,E,w,y={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},S={},k={},M={},O=[],j={},P={},R={},T=1,A=1;return E={require:function(e){return e.require?e.require:e.require=q.makeRequire(e.map)},exports:function(e){if(e.usingExports=!0,e.map.isDefine)return e.exports?j[e.map.id]=e.exports:e.exports=j[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return getOwn(y.config,e.map.id)||{}},exports:e.exports||(e.exports={})}}},b=function(e){this.events=getOwn(M,e.id)||{},this.map=e,this.shim=getOwn(y.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},b.prototype={init:function(e,t,i,r){r=r||{},this.inited||(this.factory=t,i?this.on("error",i):this.events.error&&(i=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=i,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check())},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,q.startTime=(new Date).getTime();var e=this.map;if(!this.shim)return e.prefix?this.callPlugin():this.load();q.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()}))}},load:function(){var e=this.map.url;P[e]||(P[e]=!0,q.load(this.map.id,e))},check:function(){if(this.enabled&&!this.enabling){var e,t,i=this.map.id,r=this.depExports,n=this.exports,o=this.factory;if(this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(o)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{n=q.execCb(i,o,r,n)}catch(t){e=t}else n=q.execCb(i,o,r,n);if(this.map.isDefine&&void 0===n&&((t=this.module)?n=t.exports:this.usingExports&&(n=this.exports)),e)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",c(this.error=e)}else n=o;if(this.exports=n,this.map.isDefine&&!this.ignore&&(j[i]=n,req.onResourceLoad)){var a=[];each(this.depMaps,function(e){a.push(e.normalizedMap||e)}),req.onResourceLoad(q,this.map,a)}p(i),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else hasProp(q.defQueueMap,i)||this.fetch()}},callPlugin:function(){var e=this.map,t=e.id,r=a(e.prefix);this.depMaps.push(r),u(r,"defined",bind(this,function(r){var n,o,d,f=getOwn(R,this.map.id),l=this.map.name,h=this.map.parentMap?this.map.parentMap.name:null,m=q.makeRequire(e.parentMap,{enableBuildCallback:!0});return this.map.unnormalized?(r.normalize&&(l=r.normalize(l,function(e){return i(e,h,!0)})||""),o=a(e.prefix+"!"+l,this.map.parentMap,!0),u(o,"defined",bind(this,function(e){this.map.normalizedMap=o,this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),void((d=getOwn(S,o.id))&&(this.depMaps.push(o),this.events.error&&d.on("error",bind(this,function(e){this.emit("error",e)})),d.enable()))):f?(this.map.url=q.nameToUrl(f),void this.load()):((n=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})})).error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(S,function(e){0===e.map.id.indexOf(t+"_unnormalized")&&p(e.map.id)}),c(e)}),n.fromText=bind(this,function(i,r){var o=e.name,u=a(o),d=useInteractive;r&&(i=r),d&&(useInteractive=!1),s(u),hasProp(y.config,t)&&(y.config[o]=y.config[t]);try{req.exec(i)}catch(e){return c(makeError("fromtexteval","fromText eval for "+t+" failed: "+e,e,[t]))}d&&(useInteractive=!0),this.depMaps.push(u),q.completeLoad(o),m([o],n)}),void r.load(e.name,m,n,y))})),q.enable(r,this),this.pluginMaps[r.id]=r},enable:function(){k[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var i,r,n;if("string"==typeof e){if(e=a(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,n=getOwn(E,e.id))return void(this.depExports[t]=n(this));this.depCount+=1,u(e,"defined",bind(this,function(e){this.undefed||(this.defineDep(t,e),this.check())})),this.errback?u(e,"error",bind(this,this.errback)):this.events.error&&u(e,"error",bind(this,function(e){this.emit("error",e)}))}i=e.id,r=S[i],hasProp(E,i)||!r||r.enabled||q.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(S,e.id);t&&!t.enabled&&q.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var i=this.events[e];i||(i=this.events[e]=[]),i.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),"error"===e&&delete this.events[e]}},q={config:y,contextName:e,registry:S,defined:j,urlFetched:P,defQueue:O,defQueueMap:{},Module:b,makeModuleMap:a,nextTick:req.nextTick,onError:c,configure:function(e){if(e.baseUrl&&"/"!==e.baseUrl.charAt(e.baseUrl.length-1)&&(e.baseUrl+="/"),"string"==typeof e.urlArgs){var t=e.urlArgs;e.urlArgs=function(e,i){return(-1===i.indexOf("?")?"?":"&")+t}}var i=y.shim,r={paths:!0,bundles:!0,config:!0,map:!0};eachProp(e,function(e,t){r[t]?(y[t]||(y[t]={}),mixin(y[t],e,!0,!0)):y[t]=e}),e.bundles&&eachProp(e.bundles,function(e,t){each(e,function(e){e!==t&&(R[e]=t)})}),e.shim&&(eachProp(e.shim,function(e,t){isArray(e)&&(e={deps:e}),!e.exports&&!e.init||e.exportsFn||(e.exportsFn=q.makeShimExports(e)),i[t]=e}),y.shim=i),e.packages&&each(e.packages,function(e){var t;t=(e="string"==typeof e?{name:e}:e).name,e.location&&(y.paths[t]=e.location),y.pkgs[t]=e.name+"/"+(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(S,function(e,t){e.inited||e.map.unnormalized||(e.map=a(t,null,!0))}),(e.deps||e.callback)&&q.require(e.deps||[],e.callback)},makeShimExports:function(e){return function(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}},makeRequire:function(t,n){function o(i,r,u){var d,p,f;return n.enableBuildCallback&&r&&isFunction(r)&&(r.__requireJsBuild=!0),"string"==typeof i?isFunction(r)?c(makeError("requireargs","Invalid require call"),u):t&&hasProp(E,i)?E[i](S[t.id]):req.get?req.get(q,i,t,o):(p=a(i,t,!1,!0),d=p.id,hasProp(j,d)?j[d]:c(makeError("notloaded",'Module name "'+d+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(v(),q.nextTick(function(){v(),(f=s(a(null,t))).skipMap=n.skipMap,f.init(i,r,u,{enabled:!0}),l()}),o)}return n=n||{},mixin(o,{isBrowser:isBrowser,toUrl:function(e){var r,n=e.lastIndexOf("."),o=e.split("/")[0],a="."===o||".."===o;return-1!==n&&(!a||n>1)&&(r=e.substring(n,e.length),e=e.substring(0,n)),q.nameToUrl(i(e,t&&t.id,!0),r,!0)},defined:function(e){return hasProp(j,a(e,t,!1,!0).id)},specified:function(e){return e=a(e,t,!1,!0).id,hasProp(j,e)||hasProp(S,e)}}),t||(o.undef=function(e){d();var i=a(e,t,!0),n=getOwn(S,e);n.undefed=!0,r(e),delete j[e],delete P[i.url],delete M[e],eachReverse(O,function(t,i){t[0]===e&&O.splice(i,1)}),delete q.defQueueMap[e],n&&(n.events.defined&&(M[e]=n.events),p(e))}),o},enable:function(e){getOwn(S,e.id)&&s(e).enable()},completeLoad:function(e){var t,i,r,o=getOwn(y.shim,e)||{},a=o.exports;for(d();O.length;){if(null===(i=O.shift())[0]){if(i[0]=e,t)break;t=!0}else i[0]===e&&(t=!0);h(i)}if(q.defQueueMap={},r=getOwn(S,e),!t&&!hasProp(j,e)&&r&&!r.inited){if(!(!y.enforceDefine||a&&getGlobal(a)))return n(e)?void 0:c(makeError("nodefine","No define call for "+e,null,[e]));h([e,o.deps||[],o.exportsFn])}l()},nameToUrl:function(e,t,i){var r,n,o,a,s,u,c,d=getOwn(y.pkgs,e);if(d&&(e=d),c=getOwn(R,e))return q.nameToUrl(c,t,i);if(req.jsExtRegExp.test(e))s=e+(t||"");else{for(r=y.paths,o=(n=e.split("/")).length;o>0;o-=1)if(a=n.slice(0,o).join("/"),u=getOwn(r,a)){isArray(u)&&(u=u[0]),n.splice(0,o,u);break}s=n.join("/"),s=("/"===(s+=t||(/^data\:|^blob\:|\?/.test(s)||i?"":".js")).charAt(0)||s.match(/^[\w\+\.\-]+:/)?"":y.baseUrl)+s}return y.urlArgs&&!/^blob\:/.test(s)?s+y.urlArgs(e,s):s},load:function(e,t){req.load(q,e,t)},execCb:function(e,t,i,r){return t.apply(r,i)},onScriptLoad:function(e){if("load"===e.type||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=g(e);q.completeLoad(t.id)}},onScriptError:function(e){var t=g(e);if(!n(t.id)){var i=[];return eachProp(S,function(e,r){0!==r.indexOf("_@r")&&each(e.depMaps,function(e){if(e.id===t.id)return i.push(r),!0})}),c(makeError("scripterror",'Script error for "'+t.id+(i.length?'", needed by: '+i.join(", "):'"'),e,[t.id]))}}},q.require=q.makeRequire(),q}function getInteractiveScript(){return interactiveScript&&"interactive"===interactiveScript.readyState?interactiveScript:(eachReverse(scripts(),function(e){if("interactive"===e.readyState)return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.3.5",commentRegExp=/\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/gm,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,isBrowser=!("undefined"==typeof window||"undefined"==typeof navigator||!window.document),isWebWorker=!isBrowser&&"undefined"!=typeof importScripts,readyRegExp=isBrowser&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if(void 0===define){if(void 0!==requirejs){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}void 0===require||isFunction(require)||(cfg=require,require=void 0),req=requirejs=function(e,t,i,r){var n,o,a=defContextName;return isArray(e)||"string"==typeof e||(o=e,isArray(t)?(e=t,t=i,i=r):e=[]),o&&o.context&&(a=o.context),(n=getOwn(contexts,a))||(n=contexts[a]=req.s.newContext(a)),o&&n.configure(o),n.require(e,t,i)},req.config=function(e){return req(e)},req.nextTick=void 0!==setTimeout?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],(baseElement=document.getElementsByTagName("base")[0])&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,i){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,i){var r,n=e&&e.config||{};if(isBrowser)return(r=req.createNode(n,t,i)).setAttribute("data-requirecontext",e.contextName),r.setAttribute("data-requiremodule",t),!r.attachEvent||r.attachEvent.toString&&r.attachEvent.toString().indexOf("[native code")<0||isOpera?(r.addEventListener("load",e.onScriptLoad,!1),r.addEventListener("error",e.onScriptError,!1)):(useInteractive=!0,r.attachEvent("onreadystatechange",e.onScriptLoad)),r.src=i,n.onNodeCreated&&n.onNodeCreated(r,n,t,i),currentlyAddingScript=r,baseElement?head.insertBefore(r,baseElement):head.appendChild(r),currentlyAddingScript=null,r;if(isWebWorker)try{setTimeout(function(){},0),importScripts(i),e.completeLoad(t)}catch(r){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+i,r,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"))return mainScript=dataMain,cfg.baseUrl||-1!==mainScript.indexOf("!")||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,i){var r,n;"string"!=typeof e&&(i=t,t=e,e=null),isArray(t)||(i=t,t=null),!t&&isFunction(i)&&(t=[],i.length&&(i.toString().replace(commentRegExp,commentReplace).replace(cjsRequireRegExp,function(e,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript())&&(e||(e=r.getAttribute("data-requiremodule")),n=contexts[r.getAttribute("data-requirecontext")]),n?(n.defQueue.push([e,t,i]),n.defQueueMap[e]=!0):globalDefQueue.push([e,t,i])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)}}(this,"undefined"==typeof setTimeout?void 0:setTimeout); \ No newline at end of file diff --git a/js/lib/BrowserDetect.js b/js/lib/BrowserDetect.js index 3223193..a016f7c 100644 --- a/js/lib/BrowserDetect.js +++ b/js/lib/BrowserDetect.js @@ -8,5 +8,5 @@ if(typeof browser === "undefined"){ // This means we're probably not on Firefox. } var BrowserDetect = { - usebrowser = _bd_usebrowser; + usebrowser: _bd_usebrowser } diff --git a/js/lib/StorageManager.js b/js/lib/StorageManager.js index 3408c91..48a65ab 100644 --- a/js/lib/StorageManager.js +++ b/js/lib/StorageManager.js @@ -15,7 +15,7 @@ var _sm_delopt = function(item){ } var StorageManager = { - setopt = _sm_setopt, - getopt = _sm_getopt, - delopt = _sm_delopt + setopt: _sm_setopt, + getopt: _sm_getopt, + delopt: _sm_delopt } diff --git a/js/modules-org/browser_autodetect.js b/js/modules-org/browser_autodetect.js deleted file mode 100644 index e84cd5c..0000000 --- a/js/modules-org/browser_autodetect.js +++ /dev/null @@ -1,12 +0,0 @@ -var browser_autodetect = true; -usebrowser = "firefox"; - -if(typeof browser === "undefined"){ // This means we're probably not on Firefox. - if(chrome){ - browser = chrome; - usebrowser = "chrome"; - } -} -else{ - usebrowser = "firefox"; -} diff --git a/js/modules-org/debuginit.js b/js/modules-org/debuginit.js deleted file mode 100644 index 6bb3412..0000000 --- a/js/modules-org/debuginit.js +++ /dev/null @@ -1,25 +0,0 @@ - var debugmsg = true; - var debugmsg_click = false; - var debugmsg_message = false; - var debugmsg_autoar = false; - var debugmsg_periodic = false; - var debugmsg_ui = true; - var force_conf_reload = true; - if(debugmsg || debugmsg_click || debugmsg_message || debugmsg_autoar){ - console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "); - console.log("\nLoading ultrawidify (uw)\nIf you can see this, extension at least tried to load\n\nRandom number: ",Math.floor(Math.random() * 20) + 1,"\n"); - - if(debugmsg) - console.log("Logging all"); - - if(debugmsg_click) - console.log("Logging debugmsg_click"); - - if(debugmsg_message) - console.log("Logging debugmsg_message"); - - if(debugmsg_autoar) - console.log("Logging autoar"); - - console.log(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "); - } diff --git a/js/modules-org/libopts.js b/js/modules-org/libopts.js deleted file mode 100644 index ba6d80f..0000000 --- a/js/modules-org/libopts.js +++ /dev/null @@ -1,15 +0,0 @@ -// setopt, getopt, delopt. Shrani oz. dobi oz. briše stvari iz skladišča -// setopt, getopt, delopt. They set/get/delete stuff from the storage - -function setopt(item){ - browser.storage.local.set(item); -} -function getopt(prop, callback){ - if(usebrowser == "chrome") - browser.storage.local.get(prop, callback); - else - browser.storage.local.get(prop).then(callback); -} -function delopt(item){ - browser.storage.local.remove(item); -} diff --git a/js/modules-org/optinit.js b/js/modules-org/optinit.js deleted file mode 100644 index d8a5224..0000000 --- a/js/modules-org/optinit.js +++ /dev/null @@ -1,12 +0,0 @@ -IGNORE_STORAGE_CHANGES = true; - -// getopt( "ultrawidify_uiban", function (opt) { -// if(! opt || opt.ultrawidify_uiban === undefined){ -// if(debugmsg) -// console.log("uw::extsetup_uiban | ui ban missing from storage. Setting defaults."); -// browser.storage.local.set({ultrawidify_uiban: UW_UI_BANLIST}); -// } -// } - - -IGNORE_STORAGE_CHANGES = false; diff --git a/js/modules-org/player_ui.js b/js/modules-org/player_ui.js deleted file mode 100644 index 2b3c7da..0000000 --- a/js/modules-org/player_ui.js +++ /dev/null @@ -1,287 +0,0 @@ -var UICONF; - -function uinit(){ - if(debugmsg) - console.log("player_ui::uinit | initializing elements from the webpage"); - - var site = UW_SITES[SITE]; - - if(debugmsg) - console.log("player_ui::uinit | site data:",site,"\n\n\nsite.player.name:", site.player.name,"\nsite.player.isClass:", site.player.isClass); - - SITE_ENABLED = site.enabled; - SITE_TYPE = site.type; - SITE_URL_RULES = site.urlRules; - SITE_PROPS = site; - - if(debugmsg) - console.log("player_ui::uinit | are we in iframe?", inIframe(), "does the site have a separate config for iframe?", site.iframe ? true : false ); - - if(inIframe() && site.iframe){ - console.log("player_ui::uinit | we're in iframe."); - PLAYER = site.iframe.isClass ? document.getElementsByClassName(site.iframe.name)[0] : document.getElementById(site.iframe.name); - } - else{ - PLAYER = site.player.isClass ? document.getElementsByClassName(site.player.name)[0] : document.getElementById(site.player.name); - } - - // - if( site.ui.uiMode == "native") - NATIVE_UI = true; - else - NATIVE_UI = false; - - UICONF = site.ui.uiconf; - - console.log("player_ui::uinit |\nsite.ui.uiMode: ", site.ui.uiMode,"\nsite.ui.uiMode.uiconf:",site.ui.uiconf,"\nUICONF: ", UICONF); - - IMDB_AUTOAR_ALLOWED = site.autoar_imdb.enabled; - - if(debugmsg) - console.log("player_ui::uinit | initializing elements from the webpage"); -} - -function buildUInative(){ - /** This function builds UI in the native bar. - * - */ - if(debugmsg || debugmsg_ui) - console.log("player_ui::buildUInative | starting ..."); - - if(ui_anchor){ - console.log("player_ui::buildUInative | anchor found, doing nothing"); - return; - - } - if(!ui_anchor) - mkanchor(); - - if(UW_UI_MODE == "none"){ - if(debugmsg || debugmsg_ui) - console.log("player_ui::buildUInative | usersettings say UI shouldn't be displayed. UI will not be built."); - return; - } - if(UW_UI_MODE == "compact"){ - if(debugmsg || debugmsg_ui) - console.log("player_ui::buildUInative | usersettings say UI should be compact if possible. Checking if possible."); - - if(UW_UI_BANLIST[SITE].settings !== undefined && UW_UI_BANLIST[SITE].settings != "noban"){ - if(debugmsg || debugmsg_ui) - console.log("player_ui::buildUInative | compact ui is not possible on this site. Reverting to full."); - UW_UI_MODE == "all"; - } - } - - if(debugmsg || debugmsg_ui ) - console.log("player_ui::buildUInative | starting to build UI"); - - var el; - - if(UW_UI_MODE == "compact"){ // no need for loop if all we add is the 'settings' buton - el = UW_UI_BUTTONS.settings; - uiel = mkbutton(el); - uiel.appendChild(mksubmenu(el)); - ui_anchor.appendChild(uiel); - } - else{ - for(key in UW_UI_BUTTONS){ - - el = UW_UI_BUTTONS[key]; - - if(UW_UI_BANLIST[SITE][key]){ - if(debugmsg) - console.log("player_ui::buildUInative | we don't show", key, "on site", SITE, ". Doing nothing."); - - continue; - } - - if(!el.native_bar) - continue; - - var uiel; //ui element - - if(el.button){ - uiel = mkbutton(el); - } - - if(!uiel) - continue; - - ui_anchor.appendChild(uiel); - - if(el.has_submenu){ - uiel.appendChild(mksubmenu(el)); - } - } - } - - if(debugmsg || debugmsg_ui ) - console.log("player_ui::buildUInative | ui finished"); -} - -function mksubmenu(el){ - var submenu = document.createElement("div"); - submenu.id = el.submenu_id; - submenu.className = "uw_element uw_submenu"; - - for(var i = 0; i < el.submenu.length; i++){ - if(UW_UI_BANLIST[SITE][el.submenu[i]]){ - if(debugmsg) - console.log("player_ui::mksubmenu | we don't show", el.submenu[i], "on site", SITE, ". Doing nothing."); - - continue; - } - submenu.appendChild(mkmenuitem(el.submenu[i])); - } - - return submenu; -} - -function mkmenuitem(key){ - var el = UW_UI_BUTTONS[key]; - var item = document.createElement("div"); - item.textContent = el.text; - item.className = "uw-setmenu-item uw_element"; - item.onclick = function(event){ event.stopPropagation(); el.onclick(); hideAllMenus(); }; - - if(el.has_submenu){ - item.appendChild(mksubmenu(el)); - - if(debugmsg){ - console.log("player_ui::mkmenuitem | we are:", el, "; do we have parent?",el.parent,"parent id:",UW_UI_BUTTONS[el.parent].submenu_id, UW_UI_BUTTONS[el.parent].submenu_id === "uw_settings_menu"); - } - - if(el.parent) - $(item).on("mouseenter", function(){ - // We determine where the submenu goes - to the left or to the right. showMenu handles position, - // this function gets sizes of all objects - var div = document.getElementById(UW_UI_BUTTONS[el.parent].submenu_id); - var supmenusize = div.getBoundingClientRect(); - div = document.getElementById(el.submenu_id); - var submenusize = div.getBoundingClientRect(); - var playersize = player.getBoundingClientRect(); - - if(debugmsg) - console.log("player_ui::mouseenter | parent menu size:",supmenusize,"submenu size:",submenusize,"player size:",playersize); - - showMenu(el.submenu_id, {parent:supmenusize, submenu:submenusize, player:playersize}); - }); - else - $(item).on("mouseenter", function(){showMenu(el.submenu_id)}); - - $(item).on("mouseleave", function(){hideMenu(el.submenu_id)}); - } - - return item; -} - -function mkanchor(){ - - if (debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor | starting.\nNATIVE_UI: ",NATIVE_UI); - - - if( NATIVE_UI !== true ){ - if(debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor | we don't use native UI, calling mkanchor_notify(common=true) to take over"); - - mkanchor_notify(true); - return; - } - else{ - if(debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor | will make anchor for notifications, calling mkanchor_notify(common=false)"); - - mkanchor_notify(false); - } - - if (debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor | anchor for notifications created."); - - - ui_anchor = document.createElement("div"); - ui_anchor.className = "uw_ui_anchor"; - ui_anchor.id = "uw_ui_anchor"; - - if(UICONF.uiParent.insertStrat == "prepend"){ - $(document.getElementsByClassName(UICONF.uiParent.name)[0]).prepend(ui_anchor); - } - else{ - document.getElementsByClassName(UICONF.uiParent.name)[0].appendChild(ui_anchor); - } - - if (debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor | anchor created."); - -} - -function mkanchor_notify(common){ - - if (debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor_common | starting.\n\ncommon anchor: ",common,"\nUICONF: ",UICONF,"\nUICONF.uiOffset: ",UICONF.uiOffset); - - if( document.getElementById("uw_common_anchor") ) - return; - - - var anchor = document.createElement("div"); - anchor.className = "uw_common_anchor"; - anchor.id = "uw_common_anchor"; - - // Izračunamo zamik zaradi drugih elementov na zaslonu - // Let's calculate offset due to other elements on the screen - - var offsetTop = "0px"; - - if ( UICONF.uiOffset.offsetType == "element_id" || UICONF.uiOffset.offsetType == "element_class"){ - - var blockingElement; - if( UICONF.uiOffset.offsetType == "element_id" ) - blockingElement = document.getElementById(UICONF.uiOffset.offsetBy); - else - blockingElement = document.getElementsByClassName(UICONF.uiOffset.offsetBy)[0]; - - offsetTop = blockingElement.offsetTop + blockingElement.offsetHeight + "px"; - } - else if( UICONF.uiOffset.offsetType == "css" ) - offsetTop = UICONF.uiOffset.offsetBy; - - if(debugmsg || debugmsg_ui) - console.log("player_ui::mkanchor_notify | notification box will be offset by this much:", offsetTop); - - - var padding = document.createElement("div"); - padding.style.width = "100%"; - padding.style.height = offsetTop; - - anchor.appendChild(padding); - - var notification_box = document.createElement("div"); - notification_box.style.width = "50%"; - notification_box.style.height = "25%"; - notification_box.textContent = "test box"; - - if(debugmsg) - console.log("player_ui::mkanchor_notify | this is our notification box: ", notification_box); - - anchor.appendChild(notification_box); - - PLAYER.appendChild(anchor); - - -} - -function mkbutton(el){ - if(debugmsg | debugmsg_ui) - console.log("player_ui::mkbutton | trying to make a button", el.text); - - var button = document.createElement("div"); - button.style.backgroundImage = 'url(' + resourceToUrl(el.icon) + ')'; - button.className += " uw_button uw_element"; - button.onclick = function(event) {event.stopPropagation(); el.onclick() }; - - if(debugmsg | debugmsg_ui) - console.log("player_ui::mkbutton | button completed"); - - return button; -} diff --git a/js/modules-org/uiutils.js b/js/modules-org/uiutils.js deleted file mode 100644 index 8d1c8b6..0000000 --- a/js/modules-org/uiutils.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/js/modules/ArDetect.js b/js/modules/ArDetect.js index 41d32e5..7d6f1d4 100644 --- a/js/modules/ArDetect.js +++ b/js/modules/ArDetect.js @@ -42,7 +42,7 @@ var _arSetup = function(){ //todo: change those values to push canvas off-screen - if(Debug.debug){ + if(Debug.showArDetectCanvas){ canvas.style.left = "200px"; canvas.style.top = "780px"; canvas.style.zIndex = 10000; @@ -136,9 +136,9 @@ var _ard_processAr = function(video, width, height, edge_h, edge_w){ var _ard_vdraw = function (vid, context, w, h, conf){ var blackbar_tresh = 10; // how non-black can the bar be var how_far_treshold = 8; // how much can the edge pixel vary (*4) - var msec_pause = 333; // how long is the pause between two executions — 33ms ~ 30fps + var msec_pause = 33; // how long is the pause between two executions — 33ms ~ 30fps - if(vid === undefined || vid.paused || vid.ended){ + if(vid === undefined || vid.paused || vid.ended || Status.arStrat != "auto"){ // we slow down if paused, no detection setTimeout(_ard_vdraw, 3000, vid, context, w, h); return false; diff --git a/js/modules/Resizer.js b/js/modules/Resizer.js index 29d9e2e..7f98ea8 100644 --- a/js/modules/Resizer.js +++ b/js/modules/Resizer.js @@ -258,76 +258,106 @@ var setVideoAr = function(aspect_ratio, video, player){ -// Ta funkcija ugotovi, kako se kvadrat s podanim razmerjem stranic najbolj prilega ekranu -// Predpostavimo, da so ćrne obrobe vselej zgoraj in spodaj, nikoli levo in desno. -// -// This function determines how a rectangle with a given aspect ratio best fits the monitor -// We assume letterbox is always letterbox, never pillarbox. -var _res_setBestFit = function(ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | got ar:",ar); +// // Ta funkcija ugotovi, kako se kvadrat s podanim razmerjem stranic najbolj prilega ekranu +// // Predpostavimo, da so ćrne obrobe vselej zgoraj in spodaj, nikoli levo in desno. +// // +// // This function determines how a rectangle with a given aspect ratio best fits the monitor +// // We assume letterbox is always letterbox, never pillarbox. +// var _res_setBestFit = function(ar){ +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | got ar:",ar); +// +// var player = {width: PLAYER.clientWidth, height: PLAYER.clientHeight}; +// var player_ar = player.width / player.height; +// +// var evideo = $("video")[0]; +// var video = {width: evideo.videoWidth, height: evideo.videoHeight}; +// var video_ar = video.width / video.height; +// +// // Ob predpostavki, da je argument 'ar' pravilen, naračunamo dimenzije videa glede na širino in višino predvajalnika +// // Kot rezultat laho dobimo dve možnosti: +// // A: naračunana širina je širša, kot naš zaslon —> za računanje uporabimo širino (letterbox zgoraj/spodaj, +// // levo/desno pa ne) +// // B: naračunana širina je ožja, kot naš zaslon —> za računanje uporabimo višino (letterbox levo/desno, +// // zgoraj/spodaj pa ne) +// +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | here's all we got. ar:",ar,"player:",player,"video:",video); +// +// var tru_width = player.height * ar; +// var tru_height = player.width / ar; +// +// var nv = {w: "", h: "", top: "", left: ""}; +// +// if(ar >= video_ar){ +// if(ar >= player_ar){ +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | aspect ratio is wider than player ar.") +// nv.h = player.width / video_ar; +// nv.w = nv.h * ar; +// } +// else{ +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | aspect ratio is narrower than player ar.", (player.height * ar), nv) +// nv.w = player.height * ar; +// nv.h = nv.w / video_ar; +// } +// } +// else{ +// if(ar >= player_ar){ +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | aspect ratio is wider than player ar.") +// nv.h = player.width / ar; +// nv.w = nv.h * video_ar; +// } +// else{ +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | aspect ratio is narrower than player ar.", (player.height * ar), nv) +// nv.w = player.height * video_ar; +// nv.h = nv.w / ar; +// } +// } +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | new video width and height processed. nv so far:", nv) +// +// nv.top = (player.height - nv.h)/2; +// nv.left = (player.width - nv.w)/2; +// +// if(debugmsg || debugmsg_autoar) +// console.log("uw::setBestFit | tru width:",tru_width,"(player width:",player.width,"); new video size:",nv); +// +// _res_applyCss(nv); +// console.log("uw::setBestFit | css applied"); +// } + +// Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". Približevanje opuščeno. +// handles "legacy" options, such as 'fit to widht', 'fit to height' and 'reset'. No zoom tho +var _res_legacyAr = function(action){ + var vid = $("video")[0]; + var ar = screen.width / screen.height; + var fileAr = vid.videoWidth / vid.videoHeight; - var player = {width: PLAYER.clientWidth, height: PLAYER.clientHeight}; - var player_ar = player.width / player.height; - - var evideo = $("video")[0]; - var video = {width: evideo.videoWidth, height: evideo.videoHeight}; - var video_ar = video.width / video.height; - - // Ob predpostavki, da je argument 'ar' pravilen, naračunamo dimenzije videa glede na širino in višino predvajalnika - // Kot rezultat laho dobimo dve možnosti: - // A: naračunana širina je širša, kot naš zaslon —> za računanje uporabimo širino (letterbox zgoraj/spodaj, - // levo/desno pa ne) - // B: naračunana širina je ožja, kot naš zaslon —> za računanje uporabimo višino (letterbox levo/desno, - // zgoraj/spodaj pa ne) - - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | here's all we got. ar:",ar,"player:",player,"video:",video); - - var tru_width = player.height * ar; - var tru_height = player.width / ar; - - var nv = {w: "", h: "", top: "", left: ""}; - - if(ar >= video_ar){ - if(ar >= player_ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | aspect ratio is wider than player ar.") - nv.h = player.width / video_ar; - nv.w = nv.h * ar; - } - else{ - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | aspect ratio is narrower than player ar.", (player.height * ar), nv) - nv.w = player.height * ar; - nv.h = nv.w / video_ar; - } + if(action == "fitw"){ + _res_setAr_kbd( ar > fileAr ? ar : fileAr); + return; } - else{ - if(ar >= player_ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | aspect ratio is wider than player ar.") - nv.h = player.width / ar; - nv.w = nv.h * video_ar; - } - else{ - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | aspect ratio is narrower than player ar.", (player.height * ar), nv) - nv.w = player.height * video_ar; - nv.h = nv.w / ar; - } + if(action == "fith"){ + _res_setAr_kbd( ar < fileAr ? ar : fileAr); + return; + } + if(action == "reset"){ + _res_setAr_kbd(fileAr); + return; } - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | new video width and height processed. nv so far:", nv) - - nv.top = (player.height - nv.h)/2; - nv.left = (player.width - nv.w)/2; - if(debugmsg || debugmsg_autoar) - console.log("uw::setBestFit | tru width:",tru_width,"(player width:",player.width,"); new video size:",nv); - - _res_applyCss(nv); - console.log("uw::setBestFit | css applied"); +} + +var _res_setAr_kbd = function(ar){ + if(FullScreenDetect.isFullScreen()) + _res_setAr(ar, {width: screen.width, height: screen.height} ); +// else +// _res_setAr_nonfs(ar); +// TODO: check if site supports non-fs ar } var _res_setAr = function(ar, playerDimensions){ @@ -341,6 +371,9 @@ var _res_setAr = function(ar, playerDimensions){ // spremeniti velikost predvajalnika // + if(Debug.debug) + console.log("[Resizer::_res_setArFs] ar is " ,ar, ", playerDimensions are ", playerDimensions); + var videoDimensions = { width: 0, height: 0 @@ -595,6 +628,8 @@ function _res_applyCss(dimensions){ } var Resizer = { + setAr: _res_setAr_kbd, setAr_fs: _res_setAr, - setAr_nonfs: _res_setAr_nonfs + setAr_nonfs: _res_setAr_nonfs, + legacyAr: _res_legacyAr } diff --git a/js/settings.js b/js/settings.js deleted file mode 100644 index 7066577..0000000 --- a/js/settings.js +++ /dev/null @@ -1,744 +0,0 @@ -#location res -#include lib/libopts.js -#include lib/uiutils.js -#include conf/sitesconf.js - - -var browser_autodetect = true; -var usebrowser = "chrome"; -var debugmsg = true; - -if(browser_autodetect){ - if(typeof browser === "undefined"){ - if(chrome){ - browser = chrome; - usebrowser = "chrome"; - } - } - else - usebrowser = "firefox"; -} -else{ - if(usebrowser == "chrome") - browser = chrome; -} - -var UW_SITES = {}; - -function showAbout(){ - clearPage(); - - document.getElementById("about").classList.remove("hide"); - document.getElementById("tab_about").classList.add("tab-selected"); -} -function showShortcuts(){ - clearPage(); - - document.getElementById("uw_shortcuts").classList.remove("hide"); - document.getElementById("tab_shortcuts").classList.add("tab-selected"); -} -function showGeneralSettings(){ - clearPage(); - - document.getElementById("general_settings").classList.remove("hide"); - document.getElementById("tab_general_settings").classList.add("tab-selected"); -} - -function showSites(){ - clearPage(); - document.getElementById("uw_sites").classList.remove("hide"); - document.getElementById("tab_sites").classList.add("tab-selected"); -} - -function clearPage(){ - // Hide you sections - document.getElementById("uw_shortcuts").classList.add("hide"); - document.getElementById("about").classList.add("hide"); - document.getElementById("general_settings").classList.add("hide"); - document.getElementById("uw_sites").classList.add("hide"); - - // Hide you tabs - document.getElementById("tab_shortcuts").classList.remove("tab-selected"); - document.getElementById("tab_about").classList.remove("tab-selected"); - document.getElementById("tab_general_settings").classList.remove("tab-selected"); - document.getElementById("tab_sites").classList.remove("tab-selected"); - -} - -function saveopts(){ - - var actions = ["fitw", "fith", "reset", "zoom", "unzoom", "ar219", "ar169", "ar1610", "ar43", "autoar"]; - var new_keybinds = {}; - - // Preberemo naš obrazec in iz njega naredimo nov objekt z bližnjicami. - // Let's read our form and make a new object with keybinds. - - for(var i = 0; i < actions.length; i++){ - var action = actions[i]; - var targetAR = ""; - - if(action == "ar219"){ - action = "char"; - targetAR = (21/9); - } - if(action == "ar169"){ - action = "char"; - targetAR = (16/9); - } - if(action == "ar1610"){ - action = "char"; - targetAR = (16/10); - } - if(action == "ar43"){ - action = "char"; - targetAR = (4/3); - } - - if(targetAR != ""){ - var keybind = { - action: action, - targetAR: targetAR, - key: document.querySelector("#" + actions[i] + "_letter").value.toLowerCase().replace(/[^a-z0-9]/,""), - modifiers: [] - } - } - else{ - var keybind = { - action: action, - key: document.querySelector("#" + actions[i] + "_letter").value.toLowerCase().replace(/[^a-z0-9]/,""), - modifiers: [] - } - } - - if(document.querySelector("#" + actions[i] + "_ctrl").checked) - keybind.modifiers.push("ctrl"); - if(document.querySelector("#" + actions[i] + "_alt").checked) - keybind.modifiers.push("alt"); - if(document.querySelector("#" + actions[i] + "_shift").checked) - keybind.modifiers.push("shift"); - - new_keybinds[i] = keybind; - } - - // Preveriti moramo, da nismo dvema možnostima dodali isto bližnjico. - // We need to check if all keybinds are unique. - - var fail = false; - - for(var i = 0; i < actions.length; i++) - document.querySelector("#" + actions[i] + "_letter").classList.remove("dup_keybinds"); - - for(var i = 0; i < actions.length; i++){ - if(new_keybinds[i].key == "") - continue; - - for(var j = i + 1; j < actions.length; j++){ - if(new_keybinds[i].key == new_keybinds[j].key){ - if(compareModifiers(new_keybinds[i].modifiers, new_keybinds[j].modifiers)){ - fail = true; - document.querySelector("#" + actions[i] + "_letter").classList.add("dup_keybinds"); - document.querySelector("#" + actions[j] + "_letter").classList.add("dup_keybinds"); - } - } - } - } - - if (!fail){ - browser.storage.local.set({ultrawidify_keybinds:new_keybinds}); - } - -} - -function saveAutoar(){ - setopt({ultrawidify_autoar: document.querySelector("#enable_autoar").checked}); -} - -function saveUI(){ - var show_ui = document.querySelector("#enable_ui"); - var ui_compact = document.querySelector("#enable_ui_compact"); - var optionLine = document.getElementById("compact_ui_suboption"); - - if(show_ui.checked){ - ui_compact.disabled = false; - optionLine.classList.remove("hide"); - setopt({ultrawidify_ui: ui_compact.checked ? "compact" : "all" }); - } - else{ - ui_compact.disabled = true; - optionLine.classList.add("hide"); - setopt({ultrawidify_ui: "none"}); - } -} - - -function compareModifiers(a,b){ - //NOTE: to je precej slab in neprenoslijv način primerjanja dveh tabel, ampak za naš primer deluje dovolj - // dobro, saj 'ctrl' vedno pride pred 'alt' in 'alt' vedno pride pred 'shift' (če se sploh pojavijo). - //NOTE: this is bad and totally unfoolproof practice. In our example comparing arrays the way we do works - // because values ALWAYS appear in the same order: 'ctrl' always appears before 'alt' (or it doesn't - // appear at all). 'alt' always appears before 'shift' (or it doesn't appear at all). - if(a.length != b.length) - return false; - - var match = true; - for(var i = 0; i < a.length; i++) - match &= a[i] == b[i] - - return match; -} - -function printerr(err){ - console.log(err); -} - -function gotopts(opts){ - if(!opts.ultrawidify_keybinds){ - console.log("ultrawidify keybinds are undefined. the fuck?",opts); - return; - } - var KEYBINDS = Object.keys(opts.ultrawidify_keybinds).map(function (key) { return opts.ultrawidify_keybinds[key];}); - // google chrome is really the untermensch browse // google chrome is really the untermensch browserr - var actions = ["fitw", "fith", "reset", "zoom", "unzoom", "ar219", "ar169", "ar1610", "ar43", "autoar"]; - for(var i = 0; i < actions.length; i++){ - document.querySelector("#" + actions[i] + "_letter").classList.remove("dup_keybinds"); - document.querySelector("#" + actions[i] + "_letter").value = KEYBINDS[i].key; - for(var j = 0; j < KEYBINDS[i].modifiers.length; j++){ - if(KEYBINDS[i].modifiers[j] == "ctrl") - document.querySelector("#" + actions[i] + "_ctrl").checked = true; - if(KEYBINDS[i].modifiers[j] == "alt") - document.querySelector("#" + actions[i] + "_alt").checked = true; - if(KEYBINDS[i].modifiers[j] == "shift") - document.querySelector("#" + actions[i] + "_shift").checked = true; - } - } -} - -function gotar(opts){ - -} - -function gotui(opts){ - var show_ui = document.querySelector("#enable_ui"); - var ui_compact = document.querySelector("#enable_ui_compact"); - var optionLine = document.getElementById("compact_ui_suboption"); - - if(opts.ultrawidify_ui == "all"){ - show_ui.checked = true; - ui_compact.checked = false; - optionLine.classList.remove("hide"); - } - else if(opts.ultrawidify_ui == "compact"){ - show_ui.checked = true; - ui_compact.checked = true; - optionLine.classList.remove("hide"); - } - else if(opts.ultrawidify_ui == "none"){ - show_ui.checked = false; - ui_compact.checked = false; - optionLine.classList.add("hide"); - } -} - -function gotsites(opts){ - - var list = document.getElementById("uw_sites_list"); - - if(list) - list.remove(); - - var anchor = document.getElementById("uw_sites_body"); - - // at the top of the list, there is this option to reset site config - resetLink = document.createElement("a"); - resetLink.onclick = function(){ delopt("ultrawidify_siterules"); setopt({"ultrawidify_siterules":UW_SITES}); }; - resetLink.textContent = "Reset site options to default"; - anchor.appendChild(resetLink); - - - list = document.createElement("div"); - list.id = "uw_sites_list"; - list.className = "uw_sites"; - - anchor.appendChild(list); - - uw_sites = opts.ultrawidify_siterules; - UW_SITES = uw_sites; - if(debugmsg) - console.log("uw settings::gotopts | site opts:",opts); - - for (type in {"official":1,"non-official":1,"custom":1, "add new site":1} ) { // unparalleled laziness! - if(debugmsg){ - console.log("uw settings::gotopts | adding sites of type" , type); - } - var head = document.createElement("div"); - head.className = "sites_header"; - head.textContent = type.charAt(0).toUpperCase() + type.slice(1); - - var category_desc = document.createElement("div"); - if(type == "official"){ - category_desc.innerHTML = "These sites are officially supported by the extension developer. These sites should always work. (Pro tip: if you don't want extension to run on some of the following sites, uncheck the checkbox for that site)"; - } - else if(type == "non-official"){ - category_desc.textContent = "Sites in this category have been contribued by third parties. These sites will probably work, but the developer couldn't test whether they work or not."; - } - else if(type == "custom"){ - category_desc.textContent = "In this section, you can define rules for sites that aren't supported either officially or non-officially. See [todo: link] contributing for details. If you define a custom site, please consider sharing configuration on github (see contributing for details)."; - } - else if(type == "add new site"){ - category_desc.textContent = "Add a custom site by filling the form below."; - } - - list.append(head); - list.append(category_desc); - - var category_counter = 0; - - for (site in uw_sites) { - if(debugmsg) - console.log("we're at site %s of type %s. We're %s this site.",site, uw_sites[site].type, uw_sites[site].type == type ? "processing" : "ignoring"); - - if(uw_sites[site].type == type){ - var entry = document.createElement("div"); - var header = document.createElement("div"); - - header.id = site + "_display"; - header.className = "uw_options_line site_details"; - - - var siteTitle = document.createElement("div"); - siteTitle.className = "site_name"; - { - var sitecb = mkcb(site, uw_sites[site].enabled, "siteEnabled", true); - var editTitle = mkebox(site, site, "title"); - editTitle.className = "site_title_ebox"; - siteTitle.append(sitecb); - siteTitle.append(editTitle); - - var editBtn = document.createElement("div"); - editBtn.textContent = "« edit »"; - editBtn.className = "inline_button"; - editBtn.id = site + "_edit_button"; - editBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_edit_button", ""); enableEditing(site)}); - - var saveBtn = document.createElement("div"); - saveBtn.textContent = "« save »"; - saveBtn.className = "inline_button hide"; - saveBtn.id = site + "_save_button"; - saveBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_save_button", ""); saveEdited(site)}); - - var cancelBtn = document.createElement("div"); - cancelBtn.textContent = "« cancel »"; - cancelBtn.className = "inline_button hide"; - cancelBtn.id = site + "_cancel_button"; - cancelBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_cancel_button", ""); cancelEditing(site)}); - - siteTitle.append(editBtn); - siteTitle.append(saveBtn); - siteTitle.append(cancelBtn); - } - header.appendChild(siteTitle); - entry.appendChild(header); - - var body = document.createElement("div"); - var jsonForm = document.createElement("textarea"); - jsonForm.cols = 64; - jsonForm.rows = 32; - - jsonForm.value = JSON.stringify(uw_sites[site], null, 2); - - body.appendChild(jsonForm); -// body.classNamež - entry.appendChild(body); - list.append(entry); - - - category_counter++; - } - } - - -// for (site in uw_sites){ -// if(debugmsg) -// console.log("we're at site %s of type %s. We're %s this site.",site, uw_sites[site].type, uw_sites[site].type == type ? "processing" : "ignoring"); -// -// if(uw_sites[site].type == type){ -// -// var entry = document.createElement("div"); -// var displayedInfo = document.createElement("div"); -// displayedInfo.id = site + "_display"; -// displayedInfo.className = "uw_options_line site_details"; -// -// var siteTitle = document.createElement("div"); -// siteTitle.className = "site_name"; -// -// { -// var sitecb = mkcb(site, uw_sites[site].enabled, "siteEnabled", true); -// var editTitle = mkebox(site, site, "title"); -// editTitle.className = "site_title_ebox"; -// siteTitle.append(sitecb); -// siteTitle.append(editTitle); -// -// var editBtn = document.createElement("div"); -// editBtn.textContent = "« edit »"; -// editBtn.className = "inline_button"; -// editBtn.id = site + "_edit_button"; -// editBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_edit_button", ""); enableEditing(site)}); -// -// var saveBtn = document.createElement("div"); -// saveBtn.textContent = "« save »"; -// saveBtn.className = "inline_button hide"; -// saveBtn.id = site + "_save_button"; -// saveBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_save_button", ""); saveEdited(site)}); -// -// var cancelBtn = document.createElement("div"); -// cancelBtn.textContent = "« cancel »"; -// cancelBtn.className = "inline_button hide"; -// cancelBtn.id = site + "_cancel_button"; -// cancelBtn.addEventListener("click", function(){ var site = this.id; site = site.replace("_cancel_button", ""); cancelEditing(site)}); -// -// siteTitle.append(editBtn); -// siteTitle.append(saveBtn); -// siteTitle.append(cancelBtn); -// } -// -// var siteDetails = document.createElement("div"); -// siteDetails.id = site + "_conf_details"; -// siteDetails.classList = "hide"; -// -// var urlRules = document.createElement("div"); -// { -// var urlRulesLabel = document.createElement("span"); -// urlRulesLabel.textContent = "URL rule: "; -// -// urlRulesEbox = mkebox(site, uw_sites[site].urlRules[0], "url_rules"); -// -// urlRules.append(urlRulesLabel); -// urlRules.append(urlRulesEbox); -// } -// -// var playerElement = document.createElement("div"); -// -// { -// var playerName = document.createElement("div"); -// -// var playerNameLabel = document.createElement("span"); -// -// playerNameLabel.textContent = "id of the player container:"; -// var playerNameEbox = mkebox(site, uw_sites[site].player.name, "player_name"); -// -// playerName.append(playerNameLabel); -// playerName.append(playerNameEbox); -// -// var playerClass = document.createElement("div"); -// var pcb = document.createElement("input"); -// pcb.className = site + "_ebox"; -// pcb.type = "checkbox"; -// pcb.name = site + "_pccb_name"; -// pcb.id = site + "_pccb_id"; -// pcb.checked = uw_sites[site].player.isClass; -// pcb.disabled = true; -// -// var pcblabel = document.createElement("span"); -// pcblabel.textContent = " Name of the player container is a class"; -// -// playerClass.append(pcb); -// playerClass.append(pcblabel); -// playerElement.append(playerName); -// playerElement.append(playerClass); -// } -// -// var iframe_playerName = document.createElement("div"); -// var ipn_label = document.createElement("span"); -// ipn_label.textContent = "id of the player container when in an iframe:"; -// ipn_ebox = mkebox(site, uw_sites[site].iframe ? uw_sites[site].iframe.name : "", "iframe_name"); -// iframe_playerName.append(ipn_label); -// iframe_playerName.append(ipn_ebox); -// -// var iframe_playerClass = document.createElement("div"); -// var ipc_label = document.createElement("span"); -// ipc_label.textContent = " Name of the player container is a class"; -// var ipc_cb = mkcb(site, uw_sites[site].iframe ? uw_sites[site].iframe.isClass : false, "iframe_class"); -// iframe_playerClass.append(ipc_cb); -// iframe_playerClass.append(ipc_label); -// -// -// var sampleButton = document.createElement("div"); -// var sbc = document.createElement("div"); -// var sbi = document.createElement("div"); -// var sbo = document.createElement("div"); -// var sbc_label = document.createElement("span"); -// var sbi_label = document.createElement("span"); -// var sbo_label = document.createElement("span"); -// sbc_label.textContent = "Sample button class:"; -// sbi_label.textContent = "Sample button index:"; -// sbo_label.textContent = "Use height for UI scaling"; -// var sampleButtonClass = mkebox(site, uw_sites[site].sampleButton.class, "sample_button_class"); -// var sampleButtonIndex = mkebox(site, uw_sites[site].sampleButton.index, "sample_button_index"); -// var buttonSizeBase = mkcb(site, uw_sites[site].sampleButton.buttonSizeBase == "y", "sample_button_size_base"); -// -// sbc.append(sbc_label); -// sbc.append(sampleButtonClass); -// sampleButton.append(sbc); -// -// sbi.append(sbi_label); -// sbi.append(sampleButtonIndex); -// sampleButton.append(sbi); -// -// sbo.append(buttonSizeBase); -// sbo.append(sbo_label); -// sampleButton.append(sbo); -// -// var imdbar = document.createElement("div"); -// var imdbar_cb = mkcb(site, uw_sites[site].autoar_imdb, "imdbar"); -// var imdbar_label = document.createElement("span"); -// imdbar_label.textContent = " This site supports automatic aspect ratio detection"; -// imdbar.append(imdbar_cb); -// imdbar.append(imdbar_label); -// -// var imdbar_title = document.createElement("div"); -// var it_label = document.createElement("span"); -// it_label.textContent = "id of the element containing video title:"; -// it_ebox = mkebox(site, uw_sites[site].iframe ? uw_sites[site].iframe.name : "", "imdbar_title"); -// imdbar_title.append(it_label); -// imdbar_title.append(it_ebox); -// -// var imdbar_class = document.createElement("div"); -// var ic_label = document.createElement("span"); -// ic_label.textContent = " Name of the title container is a class"; -// var ic_cb = mkcb(site, uw_sites[site].iframe ? uw_sites[site].iframe.isClass : false, "imdbar_class"); -// imdbar_class.append(ic_cb); -// imdbar_class.append(ic_label); -// -// -// -// -// -// var optionspad = document.createElement("div"); -// optionspad.textContent = "-------------"; -// -// -// siteDetails.append(urlRules); -// siteDetails.append(playerElement); -// siteDetails.append(optionspad); -// siteDetails.append(iframe_playerName); -// siteDetails.append(iframe_playerClass); -// siteDetails.append(optionspad); -// -// siteDetails.append(sampleButton); -// -// siteDetails.append(imdbar); -// siteDetails.append(imdbar_title); -// siteDetails.append(imdbar_class); -// // siteDetails.append(optionspad); -// -// -// displayedInfo.append(siteTitle); -// displayedInfo.append(siteDetails); -// -// entry.append(displayedInfo); -// -// list.append(entry); -// -// category_counter++; -// -// if(site == "dummy" && type == "add new site"){ -// if(debugmsg) -// console.log("uw settings::gotsites | we are adding dummy site"); -// enableEditing("dummy"); -// document.getElementById("dummy_title_ebox").disabled = false; -// } -// } -// } - if(! category_counter){ - var noEntriesMsg = document.createElement("div"); - noEntriesMsg.textContent = "There's no entries in this category yet"; - noEntriesMsg.classList = "red"; - list.append(noEntriesMsg); - } - } - -} - -function mkebox(site, value, id){ - var ebox = document.createElement("input"); - ebox.className = "site_details details_ebox " + site + "_ebox", - ebox.id = site + "_" + id + "_ebox"; - ebox.type = "text"; - ebox.value = value; - ebox.disabled = true; - - return ebox; -} - -function mkcb(site, checked, id, forceEnable){ - var cb = document.createElement("input"); - cb.type = "checkbox"; - cb.name = site + "_cb_name"; - cb.id = site + "_" + id + "_cb"; - cb.checked = checked; - - if(!forceEnable){ - cb.disabled = true; - cb.className = site + "_ebox"; - } - return cb; -} - -function enableEditing(site){ - showSiteDetails(site); - if(debugmsg) - console.log("uw settings :: enableEditing | enabling editing for",site); - - var formElements = document.getElementsByClassName(site + "_ebox"); - - if(!formElements) - return; - - if(debugmsg) - console.log("form elements: ", formElements); - - for(var i = 0; i < formElements.length; i++){ - formElements[i].disabled = false; - } - - var editButton = document.getElementById(site + "_edit_button"); - if( editButton ) - editButton.classList.add("hide"); - else - return; - - try{ - document.getElementById(site + "_save_button").classList.remove("hide"); - document.getElementById(site + "_cancel_button").classList.remove("hide"); - } catch (e){}; -} - -function disableEditing(site){ - var formElements = document.getElementsByClassName(site + "_ebox"); - - if(!formElements) - return; - - for(var i = 0; i < formElements.length; i++){ - formElements[i].disabled = true; - } - - var editButton = document.getElementById(site + "_edit_button"); - if( editButton ) - editButton.classList.remove("hide"); - else - return; - - try{ - document.getElementById(site + "_save_button").classList.add("hide"); - document.getElementById(site + "_cancel_button").classList.add("hide"); - } catch (e){}; -} - -function cancelEditing(site){ - if(site != "dummy"){ - disableEditing(site); - hideSiteDetails(site); - } - setSiteOpts(site, UW_SITES[site]); -} - -function saveEdited(site){ - - console.log("uw settings::saveEdited | this is our site:",site,"is this 'dummy'?", site == "dummy"); - - if(site == "dummy"){ - var newsite = getSiteOpts(site); - newsite.type = "custom"; - newsite.enabled = true; - UW_SITES[document.getElementById("dummy_title_ebox").value] = newsite; - } - else{ - UW_SITES[site] = getSiteOpts(site); -// disableEditing(site); -// hideSiteDetails(site); - } - setopt({ultrawidify_siterules: UW_SITES}); - - if(site == "dummy") - gotsites({ultrawidify_siterules: UW_SITES}); - -} - -function showSiteDetails(site){ - try{ - document.getElementById(site + "_conf_details").classList.remove("hide"); - }catch(me_outside_how_about_that){} -} - -function hideSiteDetails(site){ - try{ - document.getElementById(site + "_conf_details").classList.add("hide"); - }catch(me_outside_how_about_that){} -} - - -function getSiteOpts(site){ - var newOptions = {}; - - newOptions.urlRules = [ document.getElementById(site + "_url_rules_ebox").value ]; - newOptions.player = {}; - newOptions.player.name = document.getElementById(site + "_player_name_ebox").value; - newOptions.player.isClass = document.getElementById(site + "_pccb_id").checked; - newOptions.iframe = {}; - newOptions.iframe.name = document.getElementById(site + "_iframe_name_ebox").value; - newOptions.iframe.isClass = document.getElementById(site + "_iframe_class_cb").checked; - newOptions.autoar_imdb = {}; - newOptions.autoar_imdb.enabled = document.getElementById(site + "_imdbar_cb").value; - newOptions.autoar_imdb.title = document.getElementById(site + "_imdbar_title_ebox").value; - newOptions.autoar_imdb.isClass = document.getElementById(site + "_imdbar_class_cb").checked; - - return newOptions; -} - -function setSiteOpts(site, opts){ - document.getElementById(site + "_url_rules_ebox").value = opts.urlRules[0]; - document.getElementById(site + "_player_name_ebox").value = opts.player.name; - document.getElementById(site + "_pccb_id").checked = opts.player.isClass; - if(opts.iframe){ - document.getElementById(site + "_iframe_name_ebox").value = opts.iframe.name; - document.getElementById(site + "_iframe_class_cb").checked = opts.iframe.isClass; - } - if(opts.autoar_imdb){ - document.getElementById(site + "_imdbar_cb").checked = opts.autoar_imdb.enabled; - if(opts.autoar_imdb.enabled){ - document.getElementById(site + "_imdbar_title_ebox").value = opts.autoar_imdb.title; - document.getElementById(site + "_imdbar_class_cb").value = opts.autoar_imdb.isClass - } - } -} - - -function loadopts(){ - - getopt("ultrawidify_keybinds", gotopts); -// getopt("ultrawidify_autoar", gotar) - getopt("ultrawidify_ui", gotui); - getopt("ultrawidify_siterules", gotsites); - - // We build ui for 'site options' here -// buildSites(); - -} - - -// page init -document.addEventListener("DOMContentLoaded", loadopts); - -document.querySelector("#tab_shortcuts").addEventListener("click", showShortcuts); -document.querySelector("#tab_about").addEventListener("click", showAbout); -document.querySelector("#tab_general_settings").addEventListener("click",showGeneralSettings); -document.querySelector("#tab_sites").addEventListener("click", showSites); - -document.querySelector("#kb_save").addEventListener("click", saveopts); -document.querySelector("#kb_cancel").addEventListener("click",loadopts); - -document.querySelector("#enable_autoar").addEventListener("click",saveAutoar); -document.querySelector("#enable_ui").addEventListener("click", saveUI); -document.querySelector("#enable_ui_compact").addEventListener("click", saveUI); -getopt("ultrawidify_autoar",function(obj){document.querySelector("#enable_autoar").checked = obj.ultrawidify_autoar}); diff --git a/js/uw-org.js b/js/uw-org.js deleted file mode 100644 index f10c115..0000000 --- a/js/uw-org.js +++ /dev/null @@ -1,1493 +0,0 @@ -#location js -#include lib/debuginit.js -#include conf/uiconf.js -#include conf/sitesconf.js -#include conf/keybinds.js -#include lib/libopts.js -#include lib/browser_autodetect.js -#include lib/optinit.js -#include conf/uwvars.js -#include lib/player_ui.js - - - -const playercheck_recursion_depth_limit = 3; - -var uw_autoar_default = true; // true - autoar enabled. False - autoar disabled - -var extraClassAdded = false; -var inFullScreen = false; - -var cssmod = ""; -var zoomStep = 0.05; - -var whatdo_persistence = true; -var last_whatdo = {type: "autoar", what_do:"reset"}; -var page_url = window.location.toString(); // S pomočjo page_url določimo, na kateri spletni strani smo. -var SITE; - -var ctlbar_classnames = ["ytp-chrome-controls"]; -var serviceArray = [".video-stream"]; //Youtube - -var buttons = []; - -var IGNORE_STORAGE_CHANGES = false; - -//BEGIN determining which site we're on and the associated names - -var ui_anchor; -var player; -var vid_el; -var SAMPLE_BUTTON_CLASS; // Class of a sample button -var SAMPLE_BUTTON_INDEX = 0; // index of a sample button -var button_size_base = "x"; // Determines if size of extension buttons is defined by width or height of sample button - -var char_strat = "contain"; -var char_got_ar = false; -var char_arx; -var char_ary; -var autoar_enabled; - -var video_wrap; - - -// Here we store the window size, so we know when to trigger css change. -var winsize = {w: window.innerWidth, h: window.innerHeight}; - -// Video title for third party -var title = ""; - -// provider-specific variables - -var netflix_cltbar_visibility = -1; // -1 for invisible, anything non-negative for visible -var netflix_periodic_timer; - -// Stuff for other browsers -if(usebrowser == "chrome"){ - browser = chrome; -} - - -browser.storage.local.set({ultrawidify_siterules: UW_SITES}); - -//Na reloadu vselej odstrani vmesnik od prej -//Always remove previous UI on extension reload -var previousElements = document.getElementsByClassName("uw_element"); -if(previousElements){ - while (previousElements.length > 0){ - previousElements[0].parentNode.removeChild(previousElements[0]); - } -} - - -function init(force_reload){ - - if(debugmsg) - console.log("uw::init | starting init"); - - - var el; - for (key in UW_UI_BUTTONS){ - el = UW_UI_BUTTONS[key]; - if(el.submenu_id){ - // We defined submenus. Now let's add parent info to each submenu. - for(var i = 0; i < el.submenu.length; i++){ - UW_UI_BUTTONS[el.submenu[i]].parent = key; - } - } - } - - if(debugmsg) - console.log("uw | %cpage_url: "+page_url,"color: #99F"); - - //Youtube: - if(page_url.indexOf("youtu") != -1){ - if(debugmsg) - console.log("uw::init | we're on youtube. Page url:", page_url); - - video_wrap = "video-stream"; - return true; - } - - //Netflix: - if(page_url.indexOf("netflix.com") != -1){ - if(debugmsg) - console.log("uw::init | we're on netflix. Page url:", page_url); - - player = document.getElementById("playerContainer"); - var tmp = document.getElementsByClassName("player-status")[0]; - if(!tmp) - return false; - - vid_el = document.getElementsByTagName("video")[0]; - - SAMPLE_BUTTON_CLASS = "player-control-button player-fill-screen"; - video_wrap = "player-video-wrapper"; - button_size_base = "y"; - - return true; - } - - return false; -} - - -//END - -//BEGIN ADDING CSS - -// Če ponovno naložimo dodatek, potem odstranimo star CSS. Lahko se zgodi, da je Tam spremenil CSS in hoče -// preveriti, če stvari zgledajo tako kot morajo. Če ima en razred/id več nasprotujoćih si definicij, potem -// nam to lahko povzroča težave. Za uporabnike je načeloma odstranjevanje obstoječega CSS brezpredmetno, ker -// uporabnik ponavadi ne bo reloadal razširitve. -// -// If we reload the extension, then we also remove our old CSS. It can easily happen that Tam changed CSS a bit -// and wants to see if things look roughly the way they should. We do this because if a class/id has multiple -// mutually exclusive definitions, we can get some problems with CSS not working the way it should. People who -// aren't Tam generally don't see the benefit as they won't reload the extension — let alone reload the extension -// after messing with CSS. - -var ui_anchor = document.getElementById("uw_ui_anchor"); -var uwcss = document.getElementsByClassName("uw_css"); -while(uwcss && uwcss.length > 0) - uwcss[0].parentNode.removeChild(uwcss[0]); - -// funkcija pomagač za ustvarjanje css linkov -// helper function for creating css links -function addLink(css_url){ - var link = document.createElement("link"); - link.className = "uw_css"; - link.setAttribute("rel","stylesheet"); - link.setAttribute("type","text/css"); - link.setAttribute("href", resourceToUrl(css_url)); - $("head").append(link); -} - -// Vsaka stran dobi uw_common.css -// We add uw_common.css on every page - -addLink("res/css/uw_common.css"); - -// Če smo na Youtube/youtube popupu, dodamo css za youtube elemente -// If we're on youtube/youtube popup, we add css for youtube elements -if(page_url.indexOf("youtu") != -1){ - addLink("res/css/uw_yt.css"); -} -if(page_url.indexOf("netflix.com") != -1){ - addLink("res/css/uw_netflix.css"); -} - -//END ADDING CSS - - - -var last_location = ""; - -var KEYBINDS = {}; - -//END keybind-related stuff - -//BEGIN comms with uw-bg -function extsetup_comms(){ - if(debugmsg) - console.log("uw | Setting up comms with background scripts"); - - var num_of_msg = 0; - browser.runtime.onMessage.addListener(function (message, sender, stuff ) { - if(debugmsg || debugmsg_message) - console.log("uw::onMessage | message number: ", num_of_msg++ , "; message:", message ); - - if(message.message && message.message == "page-change"){ - if(document.getElementsByClassName("uw_element").length === 0){ - if(debugmsg) - console.log("uw::onMessage | page was updated but control buttons aren't there. Trying to readd.") - - init(); - addCtlButtons(0); - } - - - // We don't do that if we zoomed or unzoomed - if(last_whatdo.what_do != "zoom" && last_whatdo.what_do != "unzoom") - changeCSS(last_whatdo.type, last_whatdo.what_do); - - // Velikost gumbov posodobimo v vsakem primeru - // We update the button size in any case - updateUICSS(); - - if(debugmsg) - console.log("uw::onMessage | message number:",num_of_msg," »» everything is done. Buttons: ", document.getElementsByClassName("uw-button")); - } - - if(message.type && message.type == "arInfo"){ - char_got_ar = true; - char_arx = message.arx; - char_ary = message.ary; - if(debugmsg || debugmsg_message || debugmsg_autoar) - console.log("uw::onMessage | got aspect ratio (",char_arx,"/",char_ary,"), launching autochar"); - autochar(); - } - - }); - - // browser.runtime.onMessage.addListener(request => { - // console.log("Message from the background script:"); - // console.log(request.greeting); - // return Promise.resolve({response: "Hi from content script"}); - // }); - - if(debugmsg) - console.log("uw | Comms with background scripts: done"); -} -//END comms with uw-bg - -//BEGIN periodic functions -//Because onUpdated event isn't reliable enough for what we're doing on netflix. -function periodic() { - - //NOTE: this entire function needs to be tested if it still works - - if(debugmsg_periodic) - console.log("uw::periodic started!"); - - if(document.getElementsByClassName("uw_element").length === 0){ - if(debugmsg) - console.log("uw::periodic | no buttons detected. Readding."); - - init(); - buildUInative(); - updateUICSS(); - } - var w = window.innerWidth; - var h = window.innerHeight; - if(winsize.w != w && winsize.h != h){ - if(debugmsg) - console.log("uw::periodic | detected change in window size. Triggering css change"); - - winsize.w = w; - winsize.h = h; - - // We don't do that if we zoomed or unzoomed - if(last_whatdo.what_do != "zoom" && last_whatdo.what_do != "unzoom"/* && last_whatdo.type != "autoar"*/){ - changeCSS(last_whatdo.type, last_whatdo.what_do); - } - - updateUICSS(); - } - if(SITE_PROPS.uiParent.isClass) - var controls = document.getElementsByClassName(SITE_PROPS.uiParent.name)[0]; - else - var controls = document.getElementById(SITE_PROPS.uiParent.name); - if(controls){ - if(debugmsg_periodic) - console.log("uw::periodic | we found controls!"); - - - } - - if( autoar_enabled ){ - - var titleElement; - - if(SITE_PROPS.autoar_imdb.isClass) - titleElement = document.querySelector("." + SITE_PROPS.autoar_imdb.title); - else - titleElement = document.querySelector("#" + SITE_PROPS.autoar_imdb.title); - var ntitle = ""; - - //querySelector lahko vrne null, zato moramo preveriti, kaj smo dobili — drugače se .textContent pritožuje. - //querySelector can return null, in which case .textContent will complain. - if(qntitle) - ntitle = titleElement.textContent; - else{ - char_got_ar = false; - return; - } - if(titleElement && ntitle && ntitle != title){ - if(debugmsg || debugmsg_message || debugmsg_autoar) - console.log("uw::periodic | title changed. New title:",ntitle,"Old title:",title); - - char_got_ar = false; - - title = ntitle; - var sending = browser.runtime.sendMessage({ - type: "gibAspectRatio", - title: title - }); -// sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} ); - } - } - -} -//END periodic functions - - - -$(document).ready(function() { - if(debugmsg) - console.log("uw::document.ready | document is ready. Starting extension setup ..."); - extSetup(); -}); - -//BEGIN EXTENSION SETUP - -function extSetup(force_reload){ - if(debugmsg) - console.log("=============================================================================================="); - - last_location = window.location; - -// SITE = ""; - - if(force_reload){ - ui_anchor.parentNode.removeChild(ui_anchor); - ui_anchor = null; - } - - if(debugmsg){ - console.log("uw::extSetup | our current location is:", last_location, "(page_url says",page_url,")"); - console.log("uw::extSetup | initiating extension"); - } - var ini = init(); - - if(debugmsg){ - console.log("uw::extSetup | init exited with", ini); - console.log("uw::extSetup | removing existing keydown event from document (useful if extension was previously loaded and we navigated to a different video)"); - } - $(document).off("keydown"); - - if(debugmsg) - console.log("uw::extSetup | setting up keyboard shortcuts"); - - loadFromStorage(); - - //extsetup_stage2 gets called in loadFromStorage, on siterules -} - - -var EXTSETUP_STAGES = { - site: false, - uiban: false, - uimode: false, -} - -function stagetracker(op){ - if(op == "clear"){ - if(debugmsg) - console.log("uw::stagetracker | %cclearing progress (state)","color: #fff"); - for(key in EXTSETUP_STAGES) - EXTSETUP_STAGES[key] = false; - return; - } - EXTSETUP_STAGES[op] = true; - - var all_done = true; - var unfinished_stages = ""; - - for(key in EXTSETUP_STAGES){ - all_done &= EXTSETUP_STAGES[key]; - if(debugmsg && ! EXTSETUP_STAGES[key]){ - unfinished_stages += "<" + key + "> "; - } - } - - if(debugmsg) - console.log("uw::stagetracker | added stage",op, all_done ? " | all stages finished" : (" | missing stages: " + unfinished_stages)); - - return all_done; -} - - - -function extsetup_stage2(op){ - - if(debugmsg) - console.log("uw::extSetup (stage 2) | %cStarting the function. op=","color: #fff", op); - - if(! stagetracker(op) ){ - if(debugmsg) - console.log("uw::extSetup (stage 2) | %cSome stages are still uncompleted, doing nothing.","color: #fff"); - return false; - } - - extsetup_listener(); - - // SITE se nastavi v funkciji loadFromStorage. Če ni nastavljen, potem nismo na znani/podprti strani - // SITE is set in loadFromStorage. If SITE is still undefined at this point, then we aren't on a known page. - - if(debugmsg){ - console.log("\n\n\n\nuw::extSetup (stage 2) | --------- ENTERING STAGE 2 OF SETUP -----------"); - } - - if(SITE){ - - if(debugmsg){ - console.log("uw::extSetup (stage 2) | site found, starting config"); - console.log("starting uinit ..."); - console.log("progress: %c | |", "background-color: #161211; color: #f51;") - } - uinit(); - if(debugmsg){ - console.log("uw::extSetup (stage 2)\nprogress: %c |===> |\nuinit complete\n\n", "background-color: #161211; color: #f51;"); - } - - keydownSetup(); - if(debugmsg) - console.log("uw::extSetup (stage 2)\nprogress: %c |=======> |\nkeydownSetup complete\n\n", "background-color: #161211;color: #f51;"); - - extsetup_comms(); - if(debugmsg) - console.log("uw::extSetup (stage 2)\nprogress: %c |============> |\nextSetup complete; starting buildUInative\n\n", "background-color: #161211; color: #f51;"); - - buildUInative(); - if(debugmsg) - console.log("uw::extSetup (stage 2)\nprogress: %c |=================> |\nbuildUInative complete\n\n", "background-color: #161211; color: #f51;"); - - updateUICSS(); - if(debugmsg) - console.log("uw::extSetup (stage 2)\nprogress: %c |========================|\nupdateUICSS complete\n\n", "background-color: #161211; color: #f51;"); - - if(page_url.indexOf("netflix.com") != -1){ - console.log("uw::extSetup (stage 2) | starting netflix-specific setup steps"); - if(netflix_periodic_timer) - clearInterval(netflix_periodic_timer); - netflix_periodic_timer = setInterval(function(){ periodic(); }, 100); - } - } - else{ - if(debugmsg){ - console.log("uw::extSetup (stage 2) |%c SITE appears to be undefined. This means we aren't on a known/supported site. Ultrawidify shouldn't be loaded.",'background-color: #fa6607; color: #000;',"\n(note: this usually happens once after reloading this extension. If that's the case, chances are everything is fine, since this function runs twice — once with correct page_url and once with wrong one"); - debugger; - } - } - - if(debugmsg) - console.log("uw::extSetup (stage 2)\nprogress: %c |========================|\nadded canvas\n\n", "background-color: #161211; color: #f51;") - - - - - - if(debugmsg) - console.log("======================================[ setup finished ]======================================\n\n\n\n\n"); -} - - - -function loadFromStorage(){ - if(debugmsg || debugmsg_autoar) - console.log("uw::loadFromStorage | loading stuff from storage."); - - extsetup_stage2("clear"); - - getopt("ultrawidify_uiban", function(data){ - IGNORE_STORAGE_CHANGES = true; - extsetup_uiban(data); - extsetup_stage2("uiban"); - IGNORE_STORAGE_CHANGES = false; - }); - getopt("ultrawidify_siterules", function(data){ - IGNORE_STORAGE_CHANGES = true; - extsetup_siterules(data); - console.log("sss"); - extsetup_stage2("site"); - IGNORE_STORAGE_CHANGES = false; - }); - getopt("ultrawidify_ui", function(data){ - IGNORE_STORAGE_CHANGES = true; - extsetup_ui_mode(data); - console.log("sasa"); - extsetup_stage2("uimode"); - IGNORE_STORAGE_CHANGES = false; - }); - getopt("ultrawidify_autoar", function(data){ - IGNORE_STORAGE_CHANGES = true; - extsetup_autoar(data) - IGNORE_STORAGE_CHANGES = false; - }); - getopt("ultrawidify_keybinds", function(data){ - IGNORE_STORAGE_CHANGES = true; - extsetup_keybinds(data); - IGNORE_STORAGE_CHANGES = false; - }); - -} - -function keydownSetup(){ - if(debugmsg) - console.log("uw::keydownSetup | starting keybord shortcut setup"); - $(document).keydown(function (event) { // Tukaj ugotovimo, katero tipko smo pritisnili - - // Tipke upoštevamo samo, če smo v celozaslonskem načinu oz. če ne pišemo komentarja - // v nasprotnem primeru ne naredimo nič. - // We only take actions if we're in full screen or not writing a comment - if( !(inFullScreen || ( - (document.activeElement.getAttribute("role") != "textbox") && - (document.activeElement.getAttribute("type") != "text") - ))){ - if(debugmsg) - console.log("We're writing a comment or something. Doing nothing"); - return; - } - if(debugmsg || debugmsg_message){ -// console.log(KEYBINDS); - console.log("we pressed a key: ", event.key , " | keydown: ", event.keydown); - if(event.key == 'p'){ - console.log("uw/keydown: attempting to send message") - var sending = browser.runtime.sendMessage({ - type: "debug", - message: "Test message, please ignore" - }); - sending.then( function(){}, function(){console.log("uw/keydown: there was an error while sending a message")} ); - console.log("uw/keydown: test message sent! (probably)"); - return; - } - } - - for(i in KEYBINDS){ - if(debugmsg) - console.log("i: ", i, "keybinds[i]:", KEYBINDS[i]); - - if(event.key == KEYBINDS[i].key){ - if(debugmsg) - console.log("Key matches!"); - //Tipka se ujema. Preverimo še modifierje: - //Key matches. Let's check if modifiers match, too: - var mods = true; - for(var j = 0; j < KEYBINDS[i].modifiers.length; j++){ - if(KEYBINDS[i].modifiers[j] == "ctrl") - mods &= event.ctrlKey ; - else if(KEYBINDS[i].modifiers[j] == "alt") - mods &= event.altKey ; - else if(KEYBINDS[i].modifiers[j] == "shift") - mods &= event.shiftKey ; - } - if(debugmsg) - console.log("we pressed a key: ", event.key , " | mods match?", mods, "keybinding: ", KEYBINDS[i]); - if(mods){ - event.stopPropagation(); - - console.log("uw::keydown | keys match. Taking action."); - if(KEYBINDS[i].action == "char"){ - changeCSS("char", KEYBINDS[i].targetAR); - return; - } - if(KEYBINDS[i].action == "autoar"){ - manual_autoar(); - return; - } - changeCSS("anything goes", KEYBINDS[i].action); - return; - } - } - } - }); - - document.addEventListener("mozfullscreenchange", function( event ) { - onFullScreenChange(); - inFullScreen = ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width); - inFullScreen ? onFullscreenOn() : onFullscreenOff(); - }); -} - -function extsetup_siterules(opt){ - if(debugmsg) - console.log("%cuw::extsetup_siterules | setting up site rules settings","color: #88f;"); - -// if(usebrowser == "chrome") - var obj = opt; -// else -// var obj = opt[0]; - - if(!opt || obj.ultrawidify_siterules === undefined){ - if(debugmsg) - console.log("uw::extsetup_siterules | site url rules missing from storage. Setting defaults."); - browser.storage.local.set({ultrawidify_siterules: UW_SITES}); - } - else{ - UW_SITES = obj.ultrawidify_siterules; - } - - if(debugmsg) - console.log("uw::extsetup_siterules | UW_SITES:",UW_SITES,"current site:",SITE); - - var match; - for(key in UW_SITES){ - var el = UW_SITES[key]; - if(debugmsg){ - console.log("uw::extsetup_siterules | key:",key,"; el:",el, location); - } - match = false; - - for (var i = 0; i < el.urlRules.length; i++){ - if(debugmsg) - console.log("uw::extsetup_siterules | page_url:",page_url,"; el.urlRules["+i+"]:",el.urlRules[i],"; last_location.indexOf(el.urlRules["+i+"]):",page_url.indexOf(el.urlRules[i])); - match |= page_url.indexOf(el.urlRules[i]) != -1; - } - if(match){ - if(debugmsg) - console.log("uw::extsetup_siterules | we are on site", key); - - SITE = key; - return true; - } - } - if(debugmsg) - console.log("%cuw::extsetup_siterules | page_url is unknown or incorrect. Stalling extension setup","color:#fa6607","\n(NOTE: In some cases, stalling like that could be result of this extension script running twice)"); - debugging - return false; -} - -function extsetup_autoar(opt){ - if(debugmsg) - console.log("%cuw::extsetup_autoar | setting up autoar settings","color: #88f;"); - -// if(usebrowser == "chrome") - var obj = opt; -// else -// var obj = opt[0]; - - //Naslov resetiramo v vsakem primeru - //We always reset the title - title = ""; - if(obj === undefined) - return; - - - if(obj.ultrawidify_autoar === undefined){ - if(debugmsg || debugmsg_autoar) - console.log("uw::extsetup_autoar | autoar setting unavailavle in storage. Setting defaults."); - browser.storage.local.set({ultrawidify_autoar: uw_autoar_default}); - autoar_enabled = uw_autoar_default; - } - else - autoar_enabled = obj.ultrawidify_autoar; - - - if(debugmsg || debugmsg_autoar) - console.log("uw::extsetup_autoar | autoar",(autoar_enabled ? "enabled":"disabled"),"opt: ",opt); - - if(!autoar_enabled) - last_whatdo = {type: "reset", what_do:"reset"}; -} - -function extsetup_uiban(opt){ - if(debugmsg) - console.log("%cuw::extsetup_uiban | setting uiban","color: #88f;"); - - if(! opt || opt.ultrawidify_uiban === undefined){ - if(debugmsg) - console.log("uw::extsetup_uiban | ui ban missing from storage. Setting defaults."); - browser.storage.local.set({ultrawidify_uiban: UW_UI_BANLIST}); - } - else - UW_UI_BANLIST = opt.ultrawidify_uiban; - -} - -function extsetup_listener(){ - if(debugmsg) - console.log("uw::extsetup_listener | setting up listeners"); - - browser.storage.onChanged.addListener(function(){ - if(IGNORE_STORAGE_CHANGES){ - if(debugmsg) - console.log("uw:: | %c We are ignoring storage changes at the moment. Doing nothing.", "color: #fa6607") - return; - } - if(debugmsg){ - console.log("uw:: |%c calling extSetup from storage.onChanged","color:#99f"); - } - extSetup(true); - }); -} - -function extsetup_ui_mode(opt){ - if(!opt || opt.ultrawidify_ui === undefined) - UW_UI_MODE = "all"; - else - UW_UI_MODE = opt.ultrawidify_ui; - - console.log("uw::extsetup_ui_mode | ui mode:",UW_UI_MODE); -} - -function extsetup_keybinds(res){ - if(debugmsg) - console.log("%cuw::extsetup_keybinds | setting up autoar settings","color: #88f;"); - -// if(usebrowser == "chrome") - var obj = res; -// else -// var obj = res[0]; - - if(typeof uw_keybinds_storage_set === "undefined" && (jQuery.isEmptyObject(obj) || jQuery.isEmptyObject(obj.ultrawidify_keybinds)) ){ - if(debugmsg) - console.log("uw:: | No keybindings found. Loading default keybinds as keybinds"); - - browser.storage.local.set({ultrawidify_keybinds:DEFAULT_KEYBINDINGS}); - KEYBINDS = DEFAULT_KEYBINDINGS; - uw_keybinds_storage_set = true; - } - else{ - if(Object.keys(obj.ultrawidify_keybinds).length == Object.keys(DEFAULT_KEYBINDINGS).length) - KEYBINDS = obj.ultrawidify_keybinds; - else{ - KEYBINDS = obj.ultrawidify_keybinds; - - // remap 4:3 keybind from 'a' to 'c', but only if the keybind wasn't changed - var old_keybinds = Object.keys(obj.ultrawidify_keybinds); - if(KEYBINDS[old_keybinds-1].key == "a" && KEYBINDS[old_keybinds-1].modifiers == []){ - KEYBINDS[old_keybinds-1].key == "c"; - } - KEYBINDS[old_keybinds] = {action: "autoar", key: "a", modifiers: []}; - } - } - // console.log("res. ", obj.ultrawidify_keybinds); -} - - //BEGIN UI - -function check4player(recursion_depth){ - try{ - var button_width = document.getElementsByClassName(SAMPLE_BUTTON_CLASS)[SAMPLE_BUTTON_INDEX].scrollWidth; - return true; - } - catch(e){ - // Zato, ker predvajalnik ni vselej prisoten. Če predvajalnik ni prisoten, - // potem tudi knofov ni. Kar pomeni problem. - // - // Because the player isn't always there, and when the player isn't there the buttons aren't, either. - // In that case, the above statement craps out, throws an exception and trashes the extension. - if(debugmsg) - console.log("uw::addCtlButtons | seems there was a fuckup and no buttons were found on this page. No player (and therefore no buttons) found."); - - if(!recursion_depth) - recursion_depth = 0; - - // If buttons weren't found, we relaunch init() just - init(); - return recursion_depth < playercheck_recursion_depth_limit ? check4player(++recursion_depth) : false; - } - return false; -} - -function hideAllMenus(){ - var el; - for(key in UW_UI_BUTTONS){ - el = UW_UI_BUTTONS[key]; - if( el.submenu_id ) - hideMenu(el.submenu_id); - } -} - -function updateUICSS(){ - - //BEGIN INIT - var buttons = document.getElementsByClassName("uw_button"); - - var button_width = getBaseButtonWidth(); - - if(debugmsg) - console.log("uw::updateUICSS | resizing buttons. This are our buttons:",buttons," | a button is this wide:", button_width); - - if(button_width == -1 || buttons.length == 0){ //this means there's no ui - if(debugmsg) - console.log("uw::updateUICSS | UI wasn't detected, stopping"); - return; - } - - if(debugmsg){ - console.log("uw::updateUICSS | checks passed. Starting to resize ..."); - console.log("uw::updateUICSS | we have this many elements:",buttons.length, buttons); - } - //END INIT - //BEGIN update buttons - - for (var i = 0; i < buttons.length; i++){ - buttons[i].style.width = (button_width * 0.75) + "px"; - buttons[i].style.height = (button_width) + "px"; - buttons[i].style.marginLeft = (button_width * 0.3) + "px"; - buttons[i].style.paddingLeft = (button_width *0.15 ) + "px"; - buttons[i].style.paddingRight = (button_width * 0.15) + "px"; - } - - - //END update buttons - //BEGIN update menus - - var el; - var div; - for(key in UW_UI_BUTTONS){ - el = UW_UI_BUTTONS[key]; - if( el.submenu_id ){ - div = document.getElementById(el.submenu_id); - if( el.top_level) { - if( alignToBottom() ){ - div.style.bottom = button_width * 1.2 + "px"; - } - - - } - else{ - if( alignToBottom() ) { - div.style.bottom = "0px"; - } - - // this is tricky. We need to find the best place to put the (sub)menu. - } - } - } - - //END menus -} - -function getBaseButtonWidth(){ - try{ - // Na različnih straneh širino gumba poberemo na različne načine. - if(BUTTON_SIZE_BASE == "y") - return document.getElementsByClassName(SAMPLE_BUTTON_CLASS)[SAMPLE_BUTTON_INDEX].scrollHeight; - else - return document.getElementsByClassName(SAMPLE_BUTTON_CLASS)[SAMPLE_BUTTON_INDEX].scrollWidth; - } - catch(e){ - // Zato, ker predvajalnik ni vselej prisoten. Če predvajalnik ni prisoten, - // potem tudi knofov ni. Kar pomeni problem. - // - // Because the player isn't always there, and when the player isn't there the buttons aren't, either. - // In that case, the above statement craps out, throws an exception and trashes the extension. - if(debugmsg) - console.log("uw::getBaseButtonWidth | seems there was a fuckup and no buttons were found on this page. No player (and therefore no buttons) found."); - return -1; - } -} - - - -var align_to = "bottom"; //TODO — unhardcode -function alignToBottom(){ - return align_to == "bottom"; -} - - -//END UI -//END EXTENSION SETUP - -function onOpen(){ - if(debugmsg) - console.log("uw | Options page opened"); -} - -function onError(err){ - if(debugmsg){ - console.log(`Error: ${error}`); - console.log("uw | Error opening the page", err); - } -} - -function showSettings(){ - -} - -// Ta funkcija se proži, ko vstopimo ali izstopimo iz celozaslonskega načina -// This function gets triggered by full screen state change -function onFullScreenChange(){ - // Popravimo velikost gumbov - // Let's fix the button size: - var button_width = document.getElementsByClassName(SAMPLE_BUTTON_CLASS)[SAMPLE_BUTTON_INDEX].scrollWidth; - for( var i = 5; i >= 0; i--){ - buttons[i].style.width = (button_width * 0.75) + "px"; - buttons[i].style.paddingLeft = (button_width *0.15 ) + "px"; - buttons[i].style.paddingRight = (button_width * 0.15) + "px"; - } - - document.getElementById("uw-smenu").style.bottom = (button_width * 1.5) + "px"; - - //Sedaj poglejmo še, če lahko v nadzorno vrstico spravimo vse gumbe - //Let's see if we can get all the buttons in the control bar -// var rctl = document.getElementsByClassName("ytp-right-controls")[0]; - -} - - -// Ta funkcija se proži, ko gremo v celozaslonski način -// This function triggers when we enter fullscreen mode -function onFullscreenOn(){ - -} - -// Ta funkcija se proži, ko gremo ven iz celozaslonskega načina -// This function triggers when we leave fullscreen mode -function onFullscreenOff(){ - -} - -function manual_autoar(){ - if(! SITE_PROPS.autoar_imdb.enabled) - return; - - if(SITE_PROPS.autoar_imdb.isClass) - var ntitle = document.querySelector("."+ SITE_PROPS.autoar_imdb.title); // NOTE: needs to be tested - else - var ntitle = document.querySelector("#"+ SITE_PROPS.autoar_imdb.title); // NOTE: needs to be tested - - //querySelector lahko vrne null, zato moramo preveriti, kaj smo dobili — drugače se .textContent pritožuje. - //querySelector can return null, in which case .textContent will complain. - if(!ntitle) - return; - - var title = ntitle.textContent; - - char_got_ar = false; - last_whatdo = {type: "autoar", what_do:"autoar"}; - - var sending = browser.runtime.sendMessage({ - type: "gibAspectRatio", - title: title - }); -// sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} ); - -} - -function changeCSS(type, what_do){ - if(debugmsg) - console.log("uw::changeCSS | starting function. type:", type, "; what_do:",what_do,"\nPlayer element is this:",PLAYER); -// hideMenu("uw-armenu"); -// hideMenu("uw-smenu"); - - - var evideo = $("video")[0]; - - if(!evideo){ - if(debugmsg) - console.log("uw::changeCSS | no video element found. Doing nothing."); - - return; - } - - var video = { width: evideo.videoWidth, height: evideo.videoHeight }; - - var nplayer = { width: PLAYER.clientWidth, height: PLAYER.clientHeight }; - - if(debugmsg) - console.log("uw::changeCSS | video dimensions:",video.width,"x",video.height,"; player:",nplayer.width,"x",nplayer.height); - - // Youtube predvajalnik privzeto resetira CSS ob prehodu v/iz fullscreen. Tukaj shranimo zadnje dejanje, - // da ga lahko onFullscreenOff/onFullscreenOn uveljavita. - // - // Youtube player resets CSS on fullscreen state change. Here we save the last action taken, so - // onFullscreenOff/onFullscreenOn are able to preserve it (if we want). - last_whatdo = {type:type, what_do:what_do}; - - // ----------------------------------------------------------------------------------------- - // Handlanje dejanj se zgodi pod to črto - // - // Handling actions happens below this line - // ----------------------------------------------------------------------------------------- - - if (type == "autoar"){ - autochar(); - return; - } - - if (type == "char"){ - - if(debugmsg) - console.log("uw::changeCSS | trying to change aspect ratio."); - - // char = CHange Aspect Ratio - char(what_do, video, nplayer); - return; - } - - if (what_do == "reset"){ - - if(debugmsg) - console.log("uw::changeCSS | issuing reset."); - - resetCSS(video, nplayer); - return; - } - - // Velikost videa spreminjamo samo, če smo v celozaslonskem načinu ALI če NE pišemo komentarja - // Videa ne spreminjamo tudi, če uporabljamo vrstico za iskanje. - // - // We only change video size when we're in full screen OR if we are NOT writing a comment. - // We also leave video alone if we're using the search bar - - if(inFullScreen || ( - (document.activeElement.getAttribute("role") != "textbox") && - (document.activeElement.getAttribute("type") != "text") - )){ - if(debugmsg) - console.log("uw::changeCSS | trying to fit width or height"); - - changeCSS_nofs(what_do, video, nplayer); - } - - -} - - -function char(new_ar, video, player){ - - // Kot vhodni argument dobimo razmerje stranic. Problem je, ker pri nekaterih ločljivostih lahko razmerje stranic - // videa/našega zaslona minimalno odstopa od idealnega razmerja — npr 2560x1080 ni natanko 21:9, 1920x1080 ni - // natanko 16:9. Zato ob podanem razmerju stranic izračunamo dejansko razmerje stranic. - // - // The aspect ratio we get as an argument is an ideal aspect ratio. Some (most) resolutions' aspect ratios differ - // from that ideal aspect ratio (by a minimal amount) — e.g. 2560x1080 isn't exactly 21:9, 1920x1080 isn't exactly - // 16:9. What is more, both 3440x1440 and 2560x1080 are considered "21:9", but their aspect ratios are slightly - // different. This has the potential to result in annoying black bars, so we correct the aspect ratio we're given - // to something that's slightly more correct. - - var ar; - var res_219 = [ [2560,1080], [3440,1440] ]; - var res_169 = [ [1920,1080], [1280,720], [1366,768] ]; - - if(new_ar == (21/9)){ - for (var i = 0; i < res_219.length; i++){ - if( player.height == res_219[i][1]){ - ar = res_219[i][0]/res_219[i][1]; - set_video_ar( ar, video, player); - return; - } - } - } - else if(new_ar == (16/9)){ - for (var i = 0; i < res_169.length; i++){ - if( player.height == res_169[i][1]){ - ar = res_169[i][0]/res_169[i][1]; - set_video_ar( ar, video, player); - return; - } - } - } - - set_video_ar(new_ar, video, player); -} - -function autochar(){ - - if(debugmsg || debugmsg_autoar) - console.log("uw::autochar | starting. Did we get ar?",char_got_ar,"What about arx and ary?",char_arx,char_ary); - - if(!char_got_ar) - return; - - if(!char_arx || !char_ary) - return; - - var ar = char_arx / char_ary; - if(ar){ - set_best_fit(ar); - last_whatdo = {type: "autoar", what_do: "autoar"}; - } -} - -/* Tukaj povemo, kakšno razmerje stranic ima video. -// Kaj to pomeni: -// Mi rečemo, da ima video razmerje stranic 16:9. Dejanski video -// ima razmerje 4:3. To pomeni, da ima video zgoraj in spodaj črno -// obrobo, ki je nočemo, zato video povečamo toliko, da se ta obroba odreže. -// -// OBROB TUKAJ NE DODAJAMO. -// -// With this function, we specify the aspect ratio of the video. -// What does this mean? -// If we specify that the aspect ratio of a video is 16:9 when video is -// actually 4:3, that means the video has black bars above and below. -// We zoom the video just enough for the black lines to disappear. -// -// WE DO NOT ADD ANY BLACK BORDERS. If we get to a scenario when we'd have to add -// black borders, we do nothing instead. -*/ -function set_video_ar(aspect_ratio, video, player){ - var video_ar = video.width / video.height; - var display_ar = player.width / player.height; - - if(debugmsg){ - console.log("uw::set_video_ar | aspect ratio: " + aspect_ratio + "; video_ar: " + video_ar + "; display_ar: " + display_ar); - console.log("uw::set_video_ar | player dimensions: " + player.width + "x" + player.height + "; video dimensions: " + video.width + "x" + video.height); - } - - if( aspect_ratio*1.1 > video_ar && video_ar > aspect_ratio*0.9 ){ - // Ta hack nas reši problema, ki ga predstavlja spodnji if stavek — če se legit 21:9 videu na 16:9 monitorju - // obreže na 16:9, potem ga s klicem te funkcije ne moremo spremeniti nazaj na 21:9. Vendar pa bi za tak primer - // radi imeli izjemo. - // - // This hack solves the problem that the bottom if statement presents. If we crop a 21:9 video on a 16:9 monitor, - // we can't change it back to 21:9 in this function, even though we kinda want that to happen — so we add an - // exception. - if( debugmsg) - console.log("uw::set_video_ar | ar matches our display ar. resetting"); - - resetCSS(video, player); - return; - } - - // Širina, višina, top, left za nov video - // Width, height, top and left for the new video - var nv = { "w":0, "h":0, "top":0, "left":0 }; - - /* - // Video hočemo pretvoriti v video z drugačnim razmerjem stranic. - // To storimo tako, da širino videa nastavimo relativno na višino prikazovalnika, torej: - // - // širina = višina_prikazovalnika * razmerje_stranic - // višina = širina / video_ar - // - // - // - // ---------------------------------------------------------------------------------------------- - // - // In this case, the video is narrower than we want (think 4:3, which we want to make into 16:9) - // We achieve this by setting video width relative to the display width, so: - // - // width = display_height * aspect_ratio - // height = width / video_ar - // - */ - - if( video_ar <= aspect_ratio ){ - if(debugmsg){ - console.log("uw::set_video_ar | reached pre-calc. Video is taller than ar. target ar: " + aspect_ratio ); - } - - nv.w = player.height * aspect_ratio; - nv.h = nv.w / video_ar; - - nv.top = (player.height - nv.h)/2; - nv.left = (player.width - nv.w)/2; - } - else{ - if(debugmsg){ - console.log("uw::set_video_ar | reached pre-calc. Video is wider than ar. target ar: " + aspect_ratio ); - } - nv.h = player.width / aspect_ratio; - nv.w = nv.h * video_ar; - - nv.top = (player.height - nv.h)/2; - nv.left = (player.width - nv.w)/2; - } - - if(nv.w > (player.width * 1.1) && nv.h > (player.height * 1.1)) - return; - - applyCSS(nv); -} - -// Ta funkcija ugotovi, kako se kvadrat s podanim razmerjem stranic najbolj prilega ekranu -// Predpostavimo, da so ćrne obrobe vselej zgoraj in spodaj, nikoli levo in desno. -// -// This function determines how a rectangle with a given aspect ratio best fits the monitor -// We assume letterbox is always letterbox, never pillarbox. -function set_best_fit(ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | got ar:",ar); - - var player = {width: PLAYER.clientWidth, height: PLAYER.clientHeight}; - var player_ar = player.width / player.height; - - var evideo = $("video")[0]; - var video = {width: evideo.videoWidth, height: evideo.videoHeight}; - var video_ar = video.width / video.height; - - // Ob predpostavki, da je argument 'ar' pravilen, naračunamo dimenzije videa glede na širino in višino predvajalnika - // Kot rezultat laho dobimo dve možnosti: - // A: naračunana širina je širša, kot naš zaslon —> za računanje uporabimo širino (letterbox zgoraj/spodaj, - // levo/desno pa ne) - // B: naračunana širina je ožja, kot naš zaslon —> za računanje uporabimo višino (letterbox levo/desno, - // zgoraj/spodaj pa ne) - - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | here's all we got. ar:",ar,"player:",player,"video:",video); - - var tru_width = player.height * ar; - var tru_height = player.width / ar; - - var nv = {w: "", h: "", top: "", left: ""}; - - if(ar >= video_ar){ - if(ar >= player_ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | aspect ratio is wider than player ar.") - nv.h = player.width / video_ar; - nv.w = nv.h * ar; - } - else{ - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | aspect ratio is narrower than player ar.", (player.height * ar), nv) - nv.w = player.height * ar; - nv.h = nv.w / video_ar; - } - } - else{ - if(ar >= player_ar){ - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | aspect ratio is wider than player ar.") - nv.h = player.width / ar; - nv.w = nv.h * video_ar; - } - else{ - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | aspect ratio is narrower than player ar.", (player.height * ar), nv) - nv.w = player.height * video_ar; - nv.h = nv.w / ar; - } - } - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | new video width and height processed. nv so far:", nv) - - nv.top = (player.height - nv.h)/2; - nv.left = (player.width - nv.w)/2; - - if(debugmsg || debugmsg_autoar) - console.log("uw::set_best_fit | tru width:",tru_width,"(player width:",player.width,"); new video size:",nv); - - applyCSS(nv); - console.log("uw::set_best_fit | css applied"); -} - -function resetCSS(video, player){ - if(debugmsg) - console.log("uw::resetCSS | resetting video size"); - - - var nv = {"w": 0, "h": 0, "top": 0, "left": 0}; - - var vidaspect = video.width / video.height; - var scraspect = player.width / player.height; - - if( vidaspect > scraspect ){ // Video je širši od okna | video is wider than window - nv.w = player.width; - nv.h = player.width / video.width * video.height; - - // Lahko se zgodi, da je prišlo do zaokroževalne napake ter da je dejanska višina videa le nekaj pikslov drugačna, - // kot višina predvajalnika. V tem primeru zavržemo prej dobljeni rezultat in namesto tega privzamemo, da je višina - // videa enaka višini predvajalnika. - // - // It's possible to have a rounding error where calculated height of the video is only a few pixels different from - // the player height. In such cases, we discard the calculated video height and use player height instead. - - if( player.height - 4 < nv.h && nv.h < player.height + 4 ) - nv.h = player.height; - - nv.top = (player.height - nv.h) / 2; - nv.left = 0; - } - else{ - nv.h = player.height; - nv.w = player.height / video.height * video.width; - - if( player.width - 4 < nv.w && nv.w < player.width + 4) - nv.w = player.width; - - nv.top = 0; //itak zasedemo 100% višine - nv.left = (player.width - nv.w) / 2; - } - - applyCSS(nv); -} - -function changeCSS_nofs(what_do, video, player){ - if(debugmsg){ - console.log("uw::changeCSS_nofs | arguments: what_do:",what_do,"; video:", video,"; player:", player); - } - - var w; - var h; - var top; - var left; - - var evideo = $("video")[0]; - var video = {width: evideo.videoWidth, height: evideo.videoHeight, scrollw: evideo.scrollWidth, scrollh: evideo.scrollWidth}; - - var ar = video.width / video.height; - - if(debugmsg){ - console.log("uw::changeCSS_nofs | video dimensions:", video.width, "x", video.height, "; ar:",ar); - } - - if(what_do == "fitw" || what_do == "fit-width"){ - // Ker bi bilo lepo, da atribut 'top' spremenimo hkrati z width in height, moramo najprej naračunati, - // za kakšen faktor se poviša višina. To potrebujemo, da se pravilno izračuna offset. - // - // 100vw = window.innerWidth - // window.innerWidth / videoWidth = x - // - // Če pomnožimo videoHeight z x, dobimo novo višino videa. Nova višina videa je lahko večja ali manjša - // kot višina ekrana. Če je višina videa manjša kot višina ekrana, bo top pozitiven, drugače negativen: - // - // nvideoh = x * videoWidth - // top = (window.innerHeight - nvideoh) / 2 - // - // Z 2 delimo, ker hočemo video vertikalno poravnati. - - w = player.width; - h = player.width / video.width * video.height; - - if(debugmsg) - console.log("uw::changeCSS_nofs | w:",w,"; h:",h); - - top = (player.height - h) / 2; - left = 0; // Ker zavzamemo vso širino | cos we take up all the width - } - - if(what_do == "fith" || what_do == "fit-height"){ - h = player.height; - w = player.height / video.height * video.width; - - top = 0; //itak zasedemo 100% višine - left = (player.width - w) / 2; - } - - if(what_do == "zoom"){ - // Video povečujemo na tak način, da sta zoom in unzoom povečata oz. zmanjšata video za enak korak - // We do this so zoom and unzoom steps change video sizes for the same amount - - h = video.scrollh + (player.height * zoomStep); - w = video.scrollw + (player.height * zoomStep * ar); - /* Zakaj računamo širino na tak način? - // - // Predstavljajte si, da imamo 2100:900 video v 1600:900 škatli, zoomStep = 0.1. Če bi širino računali po formuli: - // - // širina = širina_videa + (širina zaslona * zoomStep) - // - // Potem bi bila nova velikost videa 2260 x 990. Razmerje stranic: 2.28 (moglo bi biti 2.33 — video je popačen). - // Zaradi tega novo širino rajši povečamo za razliko_v_višini * razmerje_stranic - // - // 2100 + (900 * 0.1 * (2100/900)) = - // 2100 + (90 * 2.333) = 2310 - // - // Razmerje stranic (2310x990) je tako 2.333 — tako, kot bi moglo biti. - // - // - // ============================================================================================================ - // - // Why did we calculate width this way? - // - // Imagine we have a 2100x900 video in a 1600:900 container, zoomStep = 0.1. If we calculated width using this: - // - // width = video_width + (container_width * zoomStep) - // - // then the new size would be 2260 x 990. This gives us an aspect ratio of 2.28 instead of 2.33 (which is what it - // should be). Because of that we rather increase the width by delta_height * aspect_ratio: - // - // 2100 + (900 * 0.1 * (2100/900)) = - // 2100 + (90 * 2.333) = 2310 - // - // This gives us the correct aspect ratio and prevents video deformations. - */ - - top = (player.height - h)/2 - left = (player.width - w) / 2; - - if (h > player.height * 4){ - if(debugmsg){ - console.log("But this video is ... I mean, it's fucking huge. This is bigger than some rooms, this is bigger than some people's flats!"); - // Insert obligatory omnishambles & coffee machine quote here - console.log("(No really, mate, you took this way too far already. Can't let you do that, Dave.)"); - } - return; - } - } - - if(what_do == "unzoom"){ - // Video povečujemo na tak način, da sta zoom in unzoom povečata oz. zmanjšata video za enak korak - // We do this so zoom and unzoom steps change video sizes for the same amount - h = video.scrollh - (player.height * zoomStep); - w = video.scrollw - (player.height * zoomStep * ar); - - top = (player.height - h)/2 - left = (player.width - w) / 2; - - if (h < player.height * 0.25){ - if(debugmsg){ - console.log("don't you think this is small enough already? You don't need to resize the video all the way down to the size smaller than your penis."); - console.log("(if you're a woman, substitute 'penis' with whatever the female equivalent is.)"); - } - return; - } - } - var dimensions = { h: h, w: w, top: top, left: left }; - applyCSS(dimensions); -} - -function applyCSS(dimensions){ - dimensions.top = Math.round(dimensions.top) + "px"; - dimensions.left = Math.round(dimensions.left) + "px"; - dimensions.w = Math.round(dimensions.w) + "px"; - dimensions.h = Math.round(dimensions.h) + "px"; - - $("video").css({"width": dimensions.w,"height": dimensions.h,"top": dimensions.top, "left": dimensions.left}); - - if(debugmsg) - console.log("uw::applycss | css applied. Dimensions/pos: w:",dimensions.w,"; h:",dimensions.h,"; top:",dimensions.top,"; left:",dimensions.left); -} - -function inIframe(){ - if(debugmsg) - console.log("uw::inIframe | checking if we're in an iframe"); - try { - return window.self !== window.top; - } catch (e) { - return true; - } -} - -function resourceToUrl(img){ - return chrome.extension.getURL(img); -} - -function showMenu(id, sizes){ - if(debugmsg){ - console.log("uw::showMenu | showing menu with id ", id, "\n\n", document.getElementById(id)); - } - - var div = document.getElementById(id); - - console.log("showMenu | asasdas", sizes); - - div.classList.add("show"); - console.log("showMenu | asasdas"); - if(sizes){ - console.log("uw::showMenu",sizes); - var player_leftmost = sizes.player.left; - var parent_leftmost = sizes.parent.left; - var player_rightmost = sizes.player.left + sizes.player.width; - var parent_rightmost = sizes.parent.left + sizes.parent.width; - - if(debugmsg){ - console.log("uw::showMenu | space on left:", parent_leftmost - player_leftmost, "| space on right:", player_rightmost - parent_rightmost); - } - - // if: - // space left of the parent is bigger than space right of the parent - if( (parent_leftmost - player_leftmost) > (player_rightmost - parent_rightmost) ){ - //player goes to the left side - if(debugmsg){ - console.log("uw::showMenu | setting position on the submenu relative to the parent. left:", -div.getBoundingClientRect().width ) - } - div.style.left = (- div.getBoundingClientRect().width ) + "px"; - } - else{ - if(debugmsg) - alert("this wasn't defined yet. pls do this. ctrl+f rivianpoint"); - div.style.left = sizes.parent.width + "px"; - } - } -} - - -function toggleMenu(id){ - if(debugmsg || debugmsg_click) - console.log("uw::toggleMenu | toggling menu with id", id, "\n\n", document.getElementById(id)); - document.getElementById(id).classList.toggle("show"); -} - -function hideMenu(id){ - if(debugmsg) - console.log("uw::hideMenu | hiding menu with id " + id); - if(document.getElementById(id)) //Safety check in case there's no element with such id - document.getElementById(id).classList.remove("show"); -} diff --git a/manifest.json b/manifest.json index 76bb12c..36aa37a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Ultrawidify-git", - "version": "2a1", + "version": "2.0a1", "icons": { "32":"res/icons/uw-32.png", @@ -20,21 +20,18 @@ "js/conf/Debug.js", "js/conf/Settings.js", "js/conf/SitesConf.js", + "js/conf/Status.js", "js/lib/FullScreenDetect.js", "js/modules/ArDetect.js", "js/modules/Resizer.js", - + "js/conf/Keybinds.js", "js/uw.js" ], "all_frames": true }], - "background": { - "scripts": ["js/jquery-3.1.1.js", "js/uw-bg.js"] - }, - "permissions": [ "tabs", "storage", "activeTab", "all_urls", "*://*.youtube.com/*", "*://youtube.com/*", "*://imdb.com/*", "*://*.imdb.com/*" ], diff --git a/res/settings.html b/res/settings.html index d034f7b..04d9a89 100644 --- a/res/settings.html +++ b/res/settings.html @@ -237,28 +237,37 @@
-
Enable automatic aspect ratio detection
-
This option uses 3rd party websites to determine aspect ratio. It may not work all the time or even properly. It only works with Netflix. This option is NOT available on Youtube.
-
+
Enable automatic aspect ratio detection
+
This option uses 3rd party websites to determine aspect ratio. It may not work all the time or even properly. It only works with Netflix. This option is NOT available on Youtube. Also deprecated probably, tamius pls remove
+
-
Show UI in the player bar
-
If this option is enabled, the extension will add some extra buttons to the player bar. If this option is disabled, setting video fit and aspect ratio is only possible via keyboard shortcuts.
-
-
If possible, use compact UI
-
With this option enabled, only 'more settings' button is enabled. Note that this option doesn't work on every site.
-
+
Enable brute-force automatic aspect ratio detection
+
Pretend that this checkbox is checked and that you can't uncheck it.

This option works by checking where black pixels end on _every_ frame (technically every ~30ms). Because of this, this option may cause lagginess and increased CPU usage. also you can't not use it because we're doing a total rewrite lol
+
+
+
Yes, the UI is gone. [..] but why is the UI gone?
+ + + + + + +
+

PLEASE NOTE: THIS IS COMPLETELY NON-FUNCTIONAL ATM. YOU CANT SET SITE-SPECIFIC OPTIONS ATM

+

Guess which thing doesn't do shit at the moment either?

+

If you guessed this page ... well.

@@ -364,12 +373,13 @@

Ultrawidify - an aspect ratio fixer for youtube (and netflix)

Created by Tamius Han (me). If something is broken, you can shout at me on github (shout nicely, though. Open an issue or bug report or something). If you're curious to see the source code, github's here. If you're looking at this page because you're bored and want to be bored some more, my website's here.

So you want to help?

-

There's a lot of sites where you can stream videos. A lot of these sites keep failing to handle aspect ratios correctly, which means it would be great if this extension worked elsewhere. Unfortunately, a lot of these sites require me to pony up some money (ayy lmao) OR just flat out block anyone who's not from the US (or their small selection of approved regions). Some sites even do both.

-

This means I'd need some help. There's two ways. One of them is to use 'inspect element' option of your browser to pick up IDs (or classnames) of certain elements. More detail here(TODO: add a link to quick tutorial).

+

There's a lot of sites where you can stream videos. A lot of these sites keep failing to handle aspect ratios correctly, which means it would be great if this extension worked elsewhere. Unfortunately, a lot of these sites require me to pony up some money (ayy lmao) OR just flat out block anyone who's not from the US (or their small selection of approved regions). Some sites even do both.

+

This means I'd need some help. There's two ways. One of them is to use 'inspect element' option of your browser to pick up IDs (or classnames) of certain elements. More detail here(TODO: add a link to quick tutorial).probably wont be necessary

The second one is, well. I won't shy away from donations either. Bonus respect for dank amounts!

Needless to say, I'll be happy and thankful regardless of the way you contribute.

Plans for the future

-

Support for more sizes. More flexible/customizable UI. Maybe (but absolutely no promises here) a bit more advanced autodetection.

+

Support for more sizes. More flexible/customizable UI. Maybe (but absolutely no promises here) a bit more advanced autodetection.

+

this is the future lol. (at least as far as autodetection goes, keybinds need to make a comeback)

Acknowledgements

This extension uses font Oxygen.

Special thanks to CD Project Red (The Witcher 2), Anet (Guild Wars 2), and Valve (CS:GO), which made it possible for me to untrigger myself after seeing so many improperly encoded videos.