Hopefully this fixes #104. Turns out 'location.host' and 'location.hostname' aren't quite interchangeable

This commit is contained in:
Tamius Han 2020-06-04 22:47:04 +02:00
parent e7957b6503
commit d59a78b039
8 changed files with 29 additions and 29 deletions

View File

@ -32,8 +32,8 @@ class ActionHandler {
var actions;
try {
if (this.settings.active.sites[window.location.host].actions) {
actions = this.settings.active.sites[window.location.host].actions;
if (this.settings.active.sites[window.location.hostname].actions) {
actions = this.settings.active.sites[window.location.hostname].actions;
} else {
actions = this.settings.active.actions;
}
@ -247,7 +247,7 @@ class ActionHandler {
this.setKeyboardLocal(cmd.arg);
}
} else {
let site = action.scope === 'site' ? window.location.host : '@global';
let site = action.scope === 'site' ? window.location.hostname : '@global';
if (cmd.action === "set-stretch") {
this.settings.active.sites[site].stretch = cmd.arg;

View File

@ -36,7 +36,7 @@ class PlayerPickerHelper {
}
findPlayerForVideo(settings, video) {
const host = window.location.host;
const host = window.location.hostname;
let element = video.parentNode;
if (this.settings.active.sites[host]

View File

@ -495,10 +495,10 @@ class Settings {
canStartAutoAr(site) {
// 'site' argument is only ever used when calling this function recursively for debugging
if (!site) {
site = window.location.host;
site = window.location.hostname;
if (!site) {
this.logger.log('warn', ['settings', 'init', 'debug'], `[Settings::canStartAutoAr] No site — even window.location.host returned nothing!: ${window.location.host}`);
this.logger.log('warn', ['settings', 'init', 'debug'], `[Settings::canStartAutoAr] No site — even window.location.hostname returned nothing!: ${window.location.hostname}`);
return false;
}
}

View File

@ -19,7 +19,7 @@ class CommsClient {
(history) => {
this.logger.log('info', 'comms', 'Sending logging-stop-and-save to background script ...');
try {
this.port.postMessage({cmd: 'logging-stop-and-save', host: window.location.host, history})
this.port.postMessage({cmd: 'logging-stop-and-save', host: window.location.hostname, history})
} catch (e) {
this.logger.log('error', 'comms', 'Failed to send message to background script. Error:', e);
}

View File

@ -29,7 +29,7 @@ class PageInfo {
try {
// request inject css immediately
const playerStyleString = this.settings.active.sites[window.location.host].css.replace('\\n', '');
const playerStyleString = this.settings.active.sites[window.location.hostname].css.replace('\\n', '');
this.comms.sendMessage({
cmd: 'inject-css',
cssString: playerStyleString
@ -39,11 +39,11 @@ class PageInfo {
}
// try getting default crop immediately.
// const cropModePersistence = this.settings.getDefaultCropPersistenceMode(window.location.host);
// const cropModePersistence = this.settings.getDefaultCropPersistenceMode(window.location.hostname);
// try {
// if (cropModePersistence === CropModePersistence.Forever) {
// this.defaultCrop = this.settings.active.sites[window.location.host].defaultCrop;
// this.defaultCrop = this.settings.active.sites[window.location.hostname].defaultCrop;
// } else if (cropModePersistence === CropModePersistence.CurrentSession) {
// this.defaultCrop = JSON.parse(sessionStorage.getItem('uw-crop-mode-session-persistence'));
// }
@ -95,7 +95,7 @@ class PageInfo {
}
try {
playerStyleString = this.settings.active.sites[window.location.host].css;
playerStyleString = this.settings.active.sites[window.location.hostname].css;
if (playerStyleString) {
this.comms.sendMessage({
cmd: 'eject-css',
@ -150,7 +150,7 @@ class PageInfo {
const oldVideoCount = this.videos.length;
try{
var vids = this.getVideos(window.location.host);
var vids = this.getVideos(window.location.hostname);
if(!vids || vids.length == 0){
this.hasVideos = false;
@ -245,9 +245,9 @@ class PageInfo {
// }
if (this.videos.length > 0) {
this.comms.registerVideo({host: window.location.host, location: window.location});
this.comms.registerVideo({host: window.location.hostname, location: window.location});
} else {
this.comms.unregisterVideo({host: window.location.host, location: window.location});
this.comms.unregisterVideo({host: window.location.hostname, location: window.location});
}
}
@ -582,12 +582,12 @@ class PageInfo {
if (persistenceMode === CropModePersistence.CurrentSession) {
sessionStorage.setItem('uw-crop-mode-session-persistence', JSON.stringify(this.currentCrop));
} else if (persistenceMode === CropModePersistence.Forever) {
if (this.settings.active.sites[window.location.host]) {
if (this.settings.active.sites[window.location.hostname]) {
// | key may be missing, so we do this
this.settings.active.sites[window.location.host]['defaultAr'] = this.currentCrop;
this.settings.active.sites[window.location.hostname]['defaultAr'] = this.currentCrop;
} else {
this.settings.active.sites[window.location.host] = this.settings.getDefaultOption();
this.settings.active.sites[window.location.host]['defaultAr'] = this.currentCrop;
this.settings.active.sites[window.location.hostname] = this.settings.getDefaultOption();
this.settings.active.sites[window.location.hostname]['defaultAr'] = this.currentCrop;
}
this.settings.saveWithoutReload();
@ -599,7 +599,7 @@ class PageInfo {
// This means crop persistance is disabled. If crop persistance is enabled, then settings for current
// site MUST exist (crop persistence mode is disabled by default)
const cropModePersistence = this.settings.getDefaultCropPersistenceMode(window.location.host);
const cropModePersistence = this.settings.getDefaultCropPersistenceMode(window.location.hostname);
if (cropModePersistence === CropModePersistence.Disabled) {
return;
@ -610,12 +610,12 @@ class PageInfo {
if (cropModePersistence === CropModePersistence.CurrentSession) {
sessionStorage.setItem('uw-crop-mode-session-persistence', JSON.stringify(ar));
} else if (cropModePersistence === CropModePersistence.Forever) {
if (this.settings.active.sites[window.location.host]) {
if (this.settings.active.sites[window.location.hostname]) {
// | key may be missing, so we do this
this.settings.active.sites[window.location.host]['defaultAr'] = ar;
this.settings.active.sites[window.location.hostname]['defaultAr'] = ar;
} else {
this.settings.active.sites[window.location.host] = this.settings.getDefaultOption();
this.settings.active.sites[window.location.host]['defaultAr'] = ar;
this.settings.active.sites[window.location.hostname] = this.settings.getDefaultOption();
this.settings.active.sites[window.location.hostname]['defaultAr'] = ar;
}
this.settings.saveWithoutReload();

View File

@ -47,7 +47,7 @@ class PlayerData {
this.periodicallyRefreshPlayerElement = false;
try {
this.periodicallyRefreshPlayerElement = this.settings.active.sites[window.location.host].DOM.player.periodicallyRefreshPlayerElement;
this.periodicallyRefreshPlayerElement = this.settings.active.sites[window.location.hostname].DOM.player.periodicallyRefreshPlayerElement;
} catch (e) {
// no biggie — that means we don't have any special settings for this site.
}
@ -226,7 +226,7 @@ class PlayerData {
}
getPlayer() {
const host = window.location.host;
const host = window.location.hostname;
let element = this.video.parentNode;
const videoWidth = this.video.offsetWidth;
const videoHeight = this.video.offsetHeight;

View File

@ -151,7 +151,7 @@ class Resizer {
return;
}
const siteSettings = this.settings.active.sites[window.location.host];
const siteSettings = this.settings.active.sites[window.location.hostname];
// reset zoom, but only on aspect ratio switch. We also know that aspect ratio gets converted to
// AspectRatio.Fixed when zooming, so let's keep that in mind
@ -354,7 +354,7 @@ class Resizer {
resetPan() {
this.pan = {};
this.videoAlignment = this.settings.getDefaultVideoAlignment(window.location.host);
this.videoAlignment = this.settings.getDefaultVideoAlignment(window.location.hostname);
}
setPan(relativeMousePosX, relativeMousePosY){
@ -585,7 +585,7 @@ class Resizer {
let extraStyleString;
try {
extraStyleString = this.settings.active.sites[window.location.host].DOM.video.additionalCss;
extraStyleString = this.settings.active.sites[window.location.hostname].DOM.video.additionalCss;
} catch (e) {
// do nothing. It's ok if no special settings are defined for this site, we'll just do defaults
}

View File

@ -48,7 +48,7 @@ class ExecAction {
if (scope === 'global') {
site = '@global';
} else if (!this.site) {
site = window.location.host;
site = window.location.hostname;
}
if (scope === 'site' && !this.settings.active.sites[site]) {