Fix #64
This commit is contained in:
parent
fd5c3fc06f
commit
ce30c6faa8
@ -818,7 +818,6 @@ var ExtensionConf = {
|
||||
ExtensionMode.Disabled, // if autoar is disabled, this setting is irrelevant
|
||||
stretch: Stretch.NoStretch, // Default stretch mode.
|
||||
videoAlignment: VideoAlignment.Center, // Video alignment
|
||||
|
||||
},
|
||||
"www.youtube.com" : {
|
||||
mode: ExtensionMode.Enabled,
|
||||
@ -837,6 +836,19 @@ var ExtensionConf = {
|
||||
type: 'official',
|
||||
stretch: Stretch.Default,
|
||||
videoAlignment: VideoAlignment.Default,
|
||||
autoarPreventConditions: { // prevents autoar on following conditions
|
||||
videoStyleString: { // if video style string thing does anything of what follows
|
||||
containsProperty: { // if video style string has any of these properties (listed as keys)
|
||||
'height': { // if 'height' property is present in style attribute, we prevent autoar from running
|
||||
allowedValues: [ // unless attribute is equal to anything in here. Optional.
|
||||
'100%'
|
||||
]
|
||||
}
|
||||
// 'width': true // this would prevent aard from runing if <video> had a 'width' property in style, regardless of value
|
||||
// could also be an empty object, in theory.
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -306,6 +306,7 @@ class Settings {
|
||||
}
|
||||
|
||||
canStartAutoAr(site) {
|
||||
// 'site' argument is only ever used when calling this function recursively for debugging
|
||||
if (!site) {
|
||||
site = window.location.host;
|
||||
|
||||
|
@ -142,6 +142,50 @@ class Resizer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ar.type === AspectRatio.Automatic ||
|
||||
ar.type === AspectRatio.Reset && this.lastAr.type === AspectRatio.Initial) {
|
||||
// some sites do things that interfere with our site (and aspect ratio setting in general)
|
||||
// first, we check whether video contains anything we don't like
|
||||
|
||||
const siteSettings = this.settings.active.sites[window.location.host];
|
||||
if (siteSettings && siteSettings.autoarPreventConditions) {
|
||||
if (siteSettings.autoarPreventConditions.videoStyleString) {
|
||||
const styleString = this.video.getAttribute('style').split(';');
|
||||
|
||||
if (siteSettings.autoarPreventConditions.videoStyleString.containsProperty) {
|
||||
const bannedProperties = siteSettings.autoarPreventConditions.videoStyleString.containsProperty;
|
||||
for (const prop in bannedProperties) {
|
||||
for (const s of styleString) {
|
||||
if (s.trim().startsWith(prop)) {
|
||||
|
||||
// check if css property has a list of allowed values:
|
||||
if (bannedProperties[prop].allowedValues) {
|
||||
const styleValue = s.split(':')[1].trim();
|
||||
|
||||
// check if property value is on the list of allowed values
|
||||
// if it's not, we aren't allowed to start aard
|
||||
if (bannedProperties[prop].allowedValues.indexOf(styleValue) === -1) {
|
||||
if (Debug.debug) {
|
||||
console.log("%c[Resizer::setAr] video style contains forbidden css property/value combo: ", "color: #900, background: #100", prop, " — we aren't allowed to start autoar.")
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// no allowed values, no problem. We have forbidden property
|
||||
// and this means aard can't start.
|
||||
if (Debug.debug) {
|
||||
console.log("%c[Resizer::setAr] video style contains forbidden css property: ", "color: #900, background: #100", prop, " — we aren't allowed to start autoar.")
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastAr) {
|
||||
this.lastAr = this.calculateRatioForLegacyOptions(lastAr);
|
||||
ar = this.calculateRatioForLegacyOptions(ar);
|
||||
@ -469,7 +513,14 @@ class Resizer {
|
||||
}
|
||||
|
||||
if(Debug.debug) {
|
||||
console.log("[Resizer::_res_computeOffsets] <rid:"+this.resizerId+"> calculated offsets:", translate);
|
||||
console.log("[Resizer::_res_computeOffsets] <rid:"+this.resizerId+"> calculated offsets:\n\n",
|
||||
'---- data in ----\n',
|
||||
'player dimensions:', {w: this.conf.player.dimensions.width, h: this.conf.player.dimensions.height},
|
||||
'video dimensions: ', {w: this.conf.video.offsetWidth, h: this.conf.video.offsetHeight},
|
||||
'stretch factors: ', stretchFactors,
|
||||
'pan & zoom: ', this.pan, this.zoom,
|
||||
'\n\n---- data out ----\n',
|
||||
'translate:', translate);
|
||||
}
|
||||
|
||||
return translate;
|
||||
|
Loading…
Reference in New Issue
Block a user