Chrome support.
This commit is contained in:
parent
442db20e4e
commit
f64bc325f3
24
js/uw-bg.js
24
js/uw-bg.js
@ -1,4 +1,7 @@
|
|||||||
debugmsg = false;
|
var browser_autodetect = true;
|
||||||
|
var usebrowser = "chrome";
|
||||||
|
|
||||||
|
debugmsg = true;
|
||||||
debugmsg_imdb = false;
|
debugmsg_imdb = false;
|
||||||
url_changed = false;
|
url_changed = false;
|
||||||
if(debugmsg){
|
if(debugmsg){
|
||||||
@ -6,6 +9,25 @@ if(debugmsg){
|
|||||||
console.log("\nLoading ultrawidify background script (uw-bg)\nIf you can see this, extension at least tried to load\n\nRandom number: ",Math.floor(Math.random() * 20) + 1,"\n");
|
console.log("\nLoading ultrawidify background script (uw-bg)\nIf you can see this, extension at least tried to load\n\nRandom number: ",Math.floor(Math.random() * 20) + 1,"\n");
|
||||||
console.log(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ");
|
console.log(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(browser_autodetect){
|
||||||
|
if(!browser){ // This means we're probably not on Firefox.
|
||||||
|
if(chrome){
|
||||||
|
browser = chrome;
|
||||||
|
usebrowser = "chrome";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usebrowser = "firefox";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(usebrowser == "chrome")
|
||||||
|
browser = chrome;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
**** script-related stuff starts here ****
|
**** script-related stuff starts here ****
|
||||||
********************************************/
|
********************************************/
|
||||||
|
124
js/uw.js
124
js/uw.js
@ -1,4 +1,7 @@
|
|||||||
var debugmsg = false;
|
var usebrowser = "chrome";
|
||||||
|
var browser_autodetect = true;
|
||||||
|
|
||||||
|
var debugmsg = true;
|
||||||
var debugmsg_click = false;
|
var debugmsg_click = false;
|
||||||
var debugmsg_message = false;
|
var debugmsg_message = false;
|
||||||
debugmsg_autoar = false;
|
debugmsg_autoar = false;
|
||||||
@ -15,6 +18,19 @@ if(debugmsg || debugmsg_click || debugmsg_message){
|
|||||||
|
|
||||||
console.log(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ");
|
console.log(". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(browser_autodetect){
|
||||||
|
if(!browser){ // This means we're probably not on Firefox.
|
||||||
|
if(chrome){
|
||||||
|
browser = chrome;
|
||||||
|
usebrowser = "chrome";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usebrowser = "firefox";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const playercheck_recursion_depth_limit = 3;
|
const playercheck_recursion_depth_limit = 3;
|
||||||
|
|
||||||
var extraClassAdded = false;
|
var extraClassAdded = false;
|
||||||
@ -61,6 +77,11 @@ var title = "";
|
|||||||
var netflix_cltbar_visibility = -1; // -1 for invisible, anything non-negative for visible
|
var netflix_cltbar_visibility = -1; // -1 for invisible, anything non-negative for visible
|
||||||
var netflix_periodic_timer;
|
var netflix_periodic_timer;
|
||||||
|
|
||||||
|
// Stuff for other browsers
|
||||||
|
if(usebrowser == "chrome"){
|
||||||
|
browser = chrome;
|
||||||
|
}
|
||||||
|
|
||||||
function init(force_reload){
|
function init(force_reload){
|
||||||
|
|
||||||
if(debugmsg)
|
if(debugmsg)
|
||||||
@ -255,44 +276,22 @@ var DEFAULT_KEYBINDINGS = {
|
|||||||
|
|
||||||
var last_location = "";
|
var last_location = "";
|
||||||
|
|
||||||
var autoar_enabled = true;
|
var autoar_enabled = false;
|
||||||
|
|
||||||
browser.storage.local.get("ultrawidify_autoar").then(function(opt){
|
|
||||||
if(!opt.ultrawidify_autoar){
|
|
||||||
browser.storage.local.set({ultrawidify_autoar: true});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.autoar_enabled = opt.ultrawidify_autoar;
|
|
||||||
if(!this.autoar_enabled)
|
|
||||||
var last_whatdo = {type: "reset", what_do:"reset"};
|
|
||||||
});
|
|
||||||
|
|
||||||
var KEYBINDS = {};
|
var KEYBINDS = {};
|
||||||
var ask4keybinds = browser.storage.local.get("ultrawidify_keybinds");
|
|
||||||
ask4keybinds.then( (res) => {
|
|
||||||
if(/*res.length == 1 &&*/ (jQuery.isEmptyObject(res[0]) || jQuery.isEmptyObject(res[0].ultrawidify_keybinds)) ){
|
|
||||||
if(debugmsg)
|
|
||||||
console.log("uw::<init keybinds> | No keybindings found. Loading default keybinds as keybinds");
|
|
||||||
|
|
||||||
browser.storage.local.set({ultrawidify_keybinds:DEFAULT_KEYBINDINGS});
|
if(usebrowser == "chrome"){
|
||||||
KEYBINDS = DEFAULT_KEYBINDINGS;
|
browser.storage.local.get("ultrawidify_autoar", function(data){extsetup_autoar(data)});
|
||||||
|
browser.storage.local.get("ultrawidify_keybinds", extsetup_keybinds);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(Object.keys(res[0].ultrawidify_keybinds).length == Object.keys(DEFAULT_KEYBINDINGS).length)
|
browser.storage.local.get("ultrawidify_autoar").then(function(opt){
|
||||||
KEYBINDS = res[0].ultrawidify_keybinds;
|
extsetup_autoar(opt);
|
||||||
else{
|
|
||||||
KEYBINDS = res[0].ultrawidify_keybinds;
|
|
||||||
|
|
||||||
// remap 4:3 keybind from 'a' to 'c', but only if the keybind wasn't changed
|
|
||||||
var old_keybinds = Object.keys(res[0].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. ", res[0].ultrawidify_keybinds);
|
|
||||||
});
|
});
|
||||||
|
var ask4keybinds = browser.storage.local.get("ultrawidify_keybinds").then(extsetup_keybinds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//END keybind-related stuff
|
//END keybind-related stuff
|
||||||
|
|
||||||
@ -369,7 +368,7 @@ function periodic() {
|
|||||||
winsize.h = h;
|
winsize.h = h;
|
||||||
|
|
||||||
// We don't do that if we zoomed or unzoomed
|
// 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"){
|
if(last_whatdo.what_do != "zoom" && last_whatdo.what_do != "unzoom"/* && last_whatdo.type != "autoar"*/){
|
||||||
changeCSS(last_whatdo.type, last_whatdo.what_do);
|
changeCSS(last_whatdo.type, last_whatdo.what_do);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +415,7 @@ function periodic() {
|
|||||||
type: "gibAspectRatio",
|
type: "gibAspectRatio",
|
||||||
title: title
|
title: title
|
||||||
});
|
});
|
||||||
sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} );
|
// sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +522,7 @@ function keydownSetup(){
|
|||||||
if(mods){
|
if(mods){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
console.log("uw::keydown | keys match. calling changeCSS()");
|
console.log("uw::keydown | keys match. Taking action.");
|
||||||
if(KEYBINDS[i].action == "char"){
|
if(KEYBINDS[i].action == "char"){
|
||||||
changeCSS("char", KEYBINDS[i].targetAR);
|
changeCSS("char", KEYBINDS[i].targetAR);
|
||||||
return;
|
return;
|
||||||
@ -546,6 +545,41 @@ function keydownSetup(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extsetup_autoar(opt){
|
||||||
|
if(!opt.ultrawidify_autoar){
|
||||||
|
browser.storage.local.set({ultrawidify_autoar: true});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.autoar_enabled = opt.ultrawidify_autoar;
|
||||||
|
if(!this.autoar_enabled)
|
||||||
|
var last_whatdo = {type: "reset", what_do:"reset"};
|
||||||
|
}
|
||||||
|
|
||||||
|
function extsetup_keybinds(res){
|
||||||
|
if(/*res.length == 1 &&*/ (jQuery.isEmptyObject(res[0]) || jQuery.isEmptyObject(res[0].ultrawidify_keybinds)) ){
|
||||||
|
if(debugmsg)
|
||||||
|
console.log("uw::<init keybinds> | No keybindings found. Loading default keybinds as keybinds");
|
||||||
|
|
||||||
|
browser.storage.local.set({ultrawidify_keybinds:DEFAULT_KEYBINDINGS});
|
||||||
|
KEYBINDS = DEFAULT_KEYBINDINGS;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(Object.keys(res[0].ultrawidify_keybinds).length == Object.keys(DEFAULT_KEYBINDINGS).length)
|
||||||
|
KEYBINDS = res[0].ultrawidify_keybinds;
|
||||||
|
else{
|
||||||
|
KEYBINDS = res[0].ultrawidify_keybinds;
|
||||||
|
|
||||||
|
// remap 4:3 keybind from 'a' to 'c', but only if the keybind wasn't changed
|
||||||
|
var old_keybinds = Object.keys(res[0].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. ", res[0].ultrawidify_keybinds);
|
||||||
|
}
|
||||||
|
|
||||||
//BEGIN UI
|
//BEGIN UI
|
||||||
|
|
||||||
function check4player(recursion_depth){
|
function check4player(recursion_depth){
|
||||||
@ -610,7 +644,7 @@ function addCtlButtons(recursion_depth){
|
|||||||
}
|
}
|
||||||
var button_def = [];
|
var button_def = [];
|
||||||
if(page_url.indexOf("netflix.com") != -1)
|
if(page_url.indexOf("netflix.com") != -1)
|
||||||
button_def = [ "fitw", "fith", "reset", "zoom", "uzoom", "settings" ]; // No settings button on netflix until further notice
|
button_def = [ "fitw", "fith", "reset", "zoom", "uzoom"/*, "settings" */]; // No settings button on netflix until further notice
|
||||||
else
|
else
|
||||||
button_def = [ "fitw", "fith", "reset", "zoom", "uzoom", "settings" ];
|
button_def = [ "fitw", "fith", "reset", "zoom", "uzoom", "settings" ];
|
||||||
|
|
||||||
@ -1015,14 +1049,14 @@ function manual_autoar(){
|
|||||||
type: "gibAspectRatio",
|
type: "gibAspectRatio",
|
||||||
title: title
|
title: title
|
||||||
});
|
});
|
||||||
sending.then( function(){}, function(err1, err2){console.log("uw::periodic: there was an error while sending a message", err1, err2)} );
|
// 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){
|
function changeCSS(type, what_do){
|
||||||
if(debugmsg)
|
if(debugmsg)
|
||||||
console.log("uw::changeCSS | starting function");
|
console.log("uw::changeCSS | starting function. type:", type, "; what_do:",what_do);
|
||||||
hideMenu("uw-armenu");
|
hideMenu("uw-armenu");
|
||||||
hideMenu("uw-smenu");
|
hideMenu("uw-smenu");
|
||||||
|
|
||||||
@ -1256,6 +1290,7 @@ function set_best_fit(ar){
|
|||||||
console.log("uw::set_best_fit | got ar:",ar);
|
console.log("uw::set_best_fit | got ar:",ar);
|
||||||
|
|
||||||
var player = {width: this.player.clientWidth, height: this.player.clientHeight};
|
var player = {width: this.player.clientWidth, height: this.player.clientHeight};
|
||||||
|
var player_ar = player.width / player.height;
|
||||||
|
|
||||||
var evideo = $("video")[0];
|
var evideo = $("video")[0];
|
||||||
var video = {width: evideo.videoWidth, height: evideo.videoHeight};
|
var video = {width: evideo.videoWidth, height: evideo.videoHeight};
|
||||||
@ -1276,12 +1311,15 @@ function set_best_fit(ar){
|
|||||||
|
|
||||||
var nv = {w: "", h: "", top: "", left: ""};
|
var nv = {w: "", h: "", top: "", left: ""};
|
||||||
|
|
||||||
if(tru_width <= player.width){
|
if(ar >= player_ar){
|
||||||
|
//Če rečemo, da je video širši kot naš kontejner, potem vzamemo širino, višino pa izračunamo
|
||||||
|
if(debugmsg)
|
||||||
|
console.log("uw::set_best_fit | aspect ratio is wider than player ar.")
|
||||||
nv.w = player.width;
|
nv.w = player.width;
|
||||||
nv.h = player.height * (ar / video_ar);
|
nv.h = player.width / video_ar;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
nv.w = player.width * (video_ar / ar);
|
nv.w = player.height * video_ar;
|
||||||
nv.h = player.height;
|
nv.h = player.height;
|
||||||
}
|
}
|
||||||
nv.top = (player.height - nv.h)/2;
|
nv.top = (player.height - nv.h)/2;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Ultrawidify-git",
|
"name": "Ultrawidify-git",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1dev",
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"32":"res/icons/uw-32.png",
|
"32":"res/icons/uw-32.png",
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
var browser_autodetect = true;
|
||||||
|
var usebrowser = "chrome";
|
||||||
|
|
||||||
|
if(browser_autodetect){
|
||||||
|
if(!browser){ // This means we're probably not on Firefox.
|
||||||
|
if(chrome){
|
||||||
|
browser = chrome;
|
||||||
|
usebrowser = "chrome";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usebrowser = "firefox";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(usebrowser == "chrome")
|
||||||
|
browser = chrome;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function showAbout(){
|
function showAbout(){
|
||||||
clearPage();
|
clearPage();
|
||||||
|
|
||||||
@ -115,7 +135,6 @@ function saveopts(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveAutoar(){
|
function saveAutoar(){
|
||||||
console.log("saving autoar. is checked?", document.querySelector("#enable_autoar").checked)
|
|
||||||
setopt({ultrawidify_autoar: document.querySelector("#enable_autoar").checked});
|
setopt({ultrawidify_autoar: document.querySelector("#enable_autoar").checked});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +145,11 @@ function setopt(item){
|
|||||||
browser.storage.local.set(item);
|
browser.storage.local.set(item);
|
||||||
}
|
}
|
||||||
function getopt(prop, callback){
|
function getopt(prop, callback){
|
||||||
|
if(usebrowser == "chrome")
|
||||||
|
browser.storage.local.get(prop, callback);
|
||||||
|
else
|
||||||
browser.storage.local.get(prop).then(callback);
|
browser.storage.local.get(prop).then(callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareModifiers(a,b){
|
function compareModifiers(a,b){
|
||||||
@ -168,8 +191,10 @@ function gotopts(opts){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadopts(){
|
function loadopts(){
|
||||||
var ask4keybinds = browser.storage.local.get("ultrawidify_keybinds");
|
if(usebrowser == "chrome")
|
||||||
ask4keybinds.then(gotopts, printerr);
|
getopt("ultrawidify_keybinds", gotopts);
|
||||||
|
else
|
||||||
|
browser.storage.local.get("ultrawidify_keybinds").then(gotopts, printerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -185,4 +210,4 @@ document.querySelector("#kb_save").addEventListener("click", saveopts);
|
|||||||
document.querySelector("#kb_cancel").addEventListener("click",loadopts);
|
document.querySelector("#kb_cancel").addEventListener("click",loadopts);
|
||||||
|
|
||||||
document.querySelector("#enable_autoar").addEventListener("click",saveAutoar);
|
document.querySelector("#enable_autoar").addEventListener("click",saveAutoar);
|
||||||
getopt("ultrawidify_autoar",function(obj){console.log("obj:",obj);document.querySelector("#enable_autoar").checked = obj.ultrawidify_autoar});
|
getopt("ultrawidify_autoar",function(obj){document.querySelector("#enable_autoar").checked = obj.ultrawidify_autoar});
|
||||||
|
Loading…
Reference in New Issue
Block a user