Merge branch 'testing'

This commit is contained in:
Tamius Han 2019-12-06 00:17:38 +01:00
commit 0c6355e370
16 changed files with 200 additions and 38 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ultravidify",
"version": "4.4.1",
"version": "4.4.2",
"description": "Aspect ratio fixer for youtube that works around some people's disability to properly encode 21:9 (and sometimes, 16:9) videos.",
"author": "Tamius Han <tamius.han@gmail.com>",
"scripts": {

View File

@ -66,14 +66,14 @@ node scripts/build-zip.js chrome
# UPLOAD TO WEB SERVER
######################################
# add ssh key, if not added
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval `ssh-agent -s`
ssh-add
fi
# # add ssh key, if not added
# if [ -z "$SSH_AUTH_SOCK" ] ; then
# eval `ssh-agent -s`
# ssh-add
# fi
# push all built stuff to the server
scp -r ./build-zip/* "ultrawidify-uploader@${RELEASE_SERVER}:${RELEASE_DIRECTORY}${BUILD_CHANNEL_DIRECTORY}"
# # push all built stuff to the server
# scp -r ./build-zip/* "ultrawidify-uploader@${RELEASE_SERVER}:${RELEASE_DIRECTORY}${BUILD_CHANNEL_DIRECTORY}"

View File

@ -5,7 +5,7 @@
</div>
<div class="flex action-name">
<span v-if="action.cmd && action.cmd.length > 1 || action.cmd[0].action === 'set-ar' && action.cmd[0].arg === AspectRatio.Fixed" class="icon red" @click="removeAction()">🗙</span>
<span v-if="action.cmd && action.cmd.length > 1 || action.cmd[0].action === 'set-ar' && action.userAdded || (action.cmd[0].arg === AspectRatio.Fixed)" class="icon red" @click="removeAction()">🗙</span>
<span v-else class="icon transparent">🗙</span> &nbsp; &nbsp;
<span class="icon" @click="editAction()">🖉</span> &nbsp; &nbsp;
{{action.name}}

View File

@ -3,6 +3,8 @@ var Stretch = Object.freeze({
Basic: 1,
Hybrid: 2,
Conditional: 3,
Fixed: 4,
FixedSource: 5,
Default: -1
});

View File

@ -72,6 +72,20 @@ var ActionList = {
},{
name: 'Thin borders',
arg: Stretch.Conditional,
},{
name: 'Fixed (source)',
arg: Stretch.FixedSource,
customArg: true,
scopes: {
page: true,
}
},{
name: 'Fixed (displayed)',
arg: Stretch.Fixed,
customArg: true,
scopes: {
page: true,
}
},{
name: 'Default',
arg: Stretch.Default,

View File

@ -1,5 +1,6 @@
// How to use:
// version: {ExtensionConf object, but only properties that get overwritten}
import Stretch from '../../common/enums/stretch.enum';
const ExtensionConfPatch = [
{
@ -146,6 +147,7 @@ const ExtensionConfPatch = [
show: true,
}
}, {
userAdded: true,
name: 'Persist crop while on page',
label: 'Until page load',
cmd: [{
@ -164,6 +166,7 @@ const ExtensionConfPatch = [
show: true,
}
}, {
userAdded: true,
name: 'Persist crop for current session',
label: 'Current session',
cmd: [{
@ -252,6 +255,50 @@ const ExtensionConfPatch = [
}
},
}
}, {
forVersion: '4.4.2',
updateFn: (userOptions, defaultOptions) => {
try {
userOptions.actions.push(
{
name: 'Stretch source to 4:3',
label: '4:3 stretch (src)',
cmd: [{
action: 'set-stretch',
arg: Stretch.FixedSource,
customArg: 1.33,
}],
scopes: {
page: {
show: true
}
},
playerUi: {
show: true,
path: 'crop'
}
}, {
name: 'Stretch source to 16:9',
label: '16:9 stretch (src)',
cmd: [{
action: 'set-stretch',
arg: Stretch.FixedSource,
customArg: 1.77,
}],
scopes: {
page: {
show: true,
}
},
playerUi: {
show: true,
path: 'crop'
}
});
} catch (e) {
console.error("PROBLEM APPLYING SETTINGS", e);
}
}
}
];

View File

@ -285,6 +285,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
userAdded: true,
name: 'Set aspect ratio to 16:9',
label: '16:9',
cmd: [{
@ -312,6 +313,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
userAdded: true,
name: 'Set aspect ratio to 21:9 (2.39:1)',
label: '21:9',
cmd: [{
@ -339,6 +341,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
userAdded: true,
name: 'Set aspect ratio to 18:9',
label: '18:9',
cmd: [{
@ -651,6 +654,41 @@ var ExtensionConf = {
show: true,
}
}
}, // NEW OPTIONS
{
name: 'Stretch source to 4:3',
label: '4:3 stretch (src)',
cmd: [{
action: 'set-stretch',
arg: Stretch.FixedSource,
customArg: 1.33,
}],
scopes: {
page: {
show: true,
}
},
playerUi: {
show: true,
path: 'crop'
}
}, {
name: 'Stretch source to 16:9',
label: '16:9 stretch (src)',
cmd: [{
action: 'set-stretch',
arg: Stretch.FixedSource,
customArg: 1.77,
}],
scopes: {
page: {
show: true,
}
},
playerUi: {
show: true,
path: 'crop'
}
},
//
// A L I G N M E N T
@ -920,8 +958,8 @@ var ExtensionConf = {
}
}
},
],
whatsNewChecked: true,
],
whatsNewChecked: true,
// -----------------------------------------
// ::: SITE CONFIGURATION :::
// -----------------------------------------

View File

@ -65,7 +65,7 @@ class CommsClient {
this.pageInfo.setVideoAlignment(message.arg, message.playing);
this.pageInfo.restoreAr();
} else if (message.cmd === "set-stretch") {
this.pageInfo.setStretchMode(message.arg, message.playing);
this.pageInfo.setStretchMode(message.arg, message.playing, message.customArg);
} else if (message.cmd === 'set-keyboard') {
this.pageInfo.setKeyboardShortcutsEnabled(message.arg)
} else if (message.cmd === "autoar-start") {

View File

@ -490,18 +490,18 @@ class PageInfo {
}
}
setStretchMode(sm, playingOnly){
setStretchMode(stretchMode, playingOnly, fixedStretchRatio){
// TODO: find a way to only change aspect ratio for one video
if (playingOnly) {
for(var vd of this.videos){
if (vd.isPlaying()) {
vd.setStretchMode(sm)
vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
} else {
for(var vd of this.videos){
vd.setStretchMode(sm)
vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
}

View File

@ -359,11 +359,11 @@ class VideoData {
this.resizer.restore();
}
setStretchMode(stretchMode){
setStretchMode(stretchMode, fixedStretchRatio){
if (this.invalid) {
return;
}
this.resizer.setStretchMode(stretchMode);
this.resizer.setStretchMode(stretchMode, fixedStretchRatio);
}
setZoom(zoomLevel, no_announce){

View File

@ -242,7 +242,9 @@ class Resizer {
}
// do stretch thingy
if (this.stretcher.mode === Stretch.NoStretch || this.stretcher.mode === Stretch.Conditional){
if (this.stretcher.mode === Stretch.NoStretch
|| this.stretcher.mode === Stretch.Conditional
|| this.stretcher.mode === Stretch.FixedSource){
var stretchFactors = this.scaler.calculateCrop(ar);
if(! stretchFactors || stretchFactors.error){
@ -255,15 +257,23 @@ class Resizer {
}
return;
}
if(this.stretcher.mode === Stretch.Conditional){
this.stretcher.applyConditionalStretch(stretchFactors, ar.ratio);
}
this.logger.log('info', 'debug', "[Resizer::setAr] Processed stretch factors for ", this.stretcher.mode === Stretch.NoStretch ? 'stretch-free crop.' : 'crop with conditional stretch.', 'Stretch factors are:', stretchFactors);
if (this.stretcher.mode === Stretch.Conditional){
this.stretcher.applyConditionalStretch(stretchFactors, ar.ratio);
} else if (this.stretcher.mode === Stretch.FixedSource) {
this.stretcher.applyStretchFixedSource(stretchFactors);
}
this.logger.log('info', 'debug', "[Resizer::setAr] Processed stretch factors for ",
this.stretcher.mode === Stretch.NoStretch ? 'stretch-free crop.' :
this.stretcher.mode === Stretch.Conditional ? 'crop with conditional stretch.' : 'crop with fixed stretch',
'Stretch factors are:', stretchFactors
);
} else if (this.stretcher.mode === Stretch.Hybrid) {
var stretchFactors = this.stretcher.calculateStretch(ar.ratio);
this.logger.log('info', 'debug', '[Resizer::setAr] Processed stretch factors for hybrid stretch/crop. Stretch factors are:', stretchFactors);
} else if (this.stretcher.mode === Stretch.Fixed) {
var stretchFactors = this.stretchFactors.calculateStretchFixed(ar.ratio)
} else if (this.stretcher.mode === Stretch.Basic) {
var stretchFactors = this.stretcher.calculateBasicStretch();
this.logger.log('info', 'debug', '[Resizer::setAr] Processed stretch factors for basic stretch. Stretch factors are:', stretchFactors);
@ -296,8 +306,8 @@ class Resizer {
return this.lastAr;
}
setStretchMode(stretchMode){
this.stretcher.setStretchMode(stretchMode);
setStretchMode(stretchMode, fixedStretchRatio){
this.stretcher.setStretchMode(stretchMode, fixedStretchRatio);
this.restore();
}
@ -459,8 +469,6 @@ class Resizer {
'\nwdiff, hdiffAfterZoom:', wdiffAfterZoom, 'x', hdiffAfterZoom,
'\n\n---- data out ----\n',
'translate:', translate);
console.trace();
return translate;
}

View File

@ -15,12 +15,16 @@ class Stretcher {
this.logger = videoData.logger;
this.settings = videoData.settings;
this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
this.fixedStretchRatio = undefined;
}
setStretchMode(stretchMode) {
setStretchMode(stretchMode, fixedStretchRatio) {
if (stretchMode === Stretch.Default) {
this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
} else {
if (stretchMode === Stretch.Fixed || stretchMode == Stretch.FixedSource) {
this.fixedStretchRatio = fixedStretchRatio;
}
this.mode = stretchMode;
}
}
@ -95,9 +99,43 @@ class Stretcher {
};
}
calculateStretch(actualAr) {
var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
var videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
applyStretchFixedSource(postCropStretchFactors) {
const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
const playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
const squezeFactor = this.fixedStretchRatio / videoAr;
// Whether squeezing happens on X or Y axis depends on whether required AR is wider or narrower than
// the player, in which the video is displayed
// * we squeeze X axis, if target AR is narrower than player size
// * we squeeze Y axis, if target AR is wider than the player size
this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we got:
postCropStretchFactors: x=${postCropStretchFactors.xFactor} y=${postCropStretchFactors.yFactor}
fixedStretchRatio: ${this.fixedStretchRatio}
videoAr: ${videoAr}
playerAr: ${playerAr}
squeezeFactor: ${squezeFactor}`, '\nvideo', this.conf.video);
if (this.fixedStretchRatio < playerAr) {
postCropStretchFactors.xFactor *= squezeFactor;
} else {
postCropStretchFactors.yFactor *= squezeFactor;
}
this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we'll apply:\npostCropStretchFactors: x=${postCropStretchFactors.x} y=${postCropStretchFactors.y}`);
return postCropStretchFactors;
}
calculateStretchFixed(actualAr) {
return this.calculateStretch(actualAr, this.fixedStretchRatio);
}
calculateStretch(actualAr, playerArOverride) {
const playerAr = playerArOverride || this.conf.player.dimensions.width / this.conf.player.dimensions.height;
const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
if (! actualAr){
actualAr = playerAr;
@ -158,7 +196,7 @@ class Stretcher {
// video is letterboxed by player
// actual is pillarboxed by video
stretchFactors.xFactor = actualAr / playerAr;
stretchFActors.yFactor = actualAr / playerAr;
stretchFactors.yFactor = actualAr / playerAr;
this.logger.log('info', 'stretcher', "[Stretcher.js::calculateStretch] stretching strategy 5")
} else {

View File

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Ultrawidify",
"description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.",
"version": "4.4.1",
"version": "4.4.2",
"applications": {
"gecko": {
"id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"

View File

@ -229,7 +229,7 @@ export default {
},
saveSettings() {
if (this.currentCmdIndex < 0) {
this.settings.active.actions.push(this.action);
this.settings.active.actions.push({...this.action, ...{userAdded: true}});
}
this.settings.save();
this.close();

View File

@ -22,6 +22,7 @@
>
</ShortcutButton>
</div>
<div><small>You can change or add additional aspect ratios on <a href="#" @click="openOptionsPage()">the settings page</a> (in 'actions&shortcuts' menu).</small></div>
</div>
<div v-if="true"
@ -155,6 +156,9 @@ export default {
}
},
methods: {
async openOptionsPage() {
browser.runtime.openOptionsPage();
},
execAction(action) {
this.exec.exec(action, 'page', this.frame);
},

View File

@ -2,12 +2,23 @@
<div>
<h2>What's new</h2>
<p>Full changelog for older versions <a href="https://github.com/xternal7/ultrawidify/blob/master/CHANGELOG.md">is available here</a>.</p>
<p class="label">4.4.1</p>
<p class="label">4.4.2</p>
<ul>
<li>Changes to player detection that fix issues with vk</li>
<li>Extension tries to avoid setting aspect ratio pointlessly</li>
<li>Fixed (hopefully) mailto: and reddit compose links.</li>
<li>When reporting bugs, email/reddit template now automatically gathers browser, extension version and OS.</li>
<li>Stretching supports two new kinds of stretching (both hybrid). One stretches (or squishes) the video before
applying any possible crop, the other option first crops and then stretches/squishes to specified aspect ratio.<br/>
Especially the first option should be great for all men of culture who prefer watching content in its native aspect
ratio (even if that means seeing black bars) who get outright triggered when some uncivilized barbarians stretch 4:3
content to 16:9. You're welcome.<br/><small>Okay maybe I shouldn't soapboax like that in my patch notes.</small><br/>
There's two new buttons in 'stretch' section (video only). You can add more in extension settings if you want.<br/>
<b>This is experimental af and wasn't tested thoroughly — feedback welcome.</b> Links in 'report a problem' tab of
this popup.
</li>
<li>Disney+ didn't work for some. I've attempted to do a fix, but I am unable to test it (by the virtue of D+ not
being available in my country). If Disney+ continues to be problematic, I will probably need some help with it.
I would love to hear some feedback on whether extension works on Disney+ or not please consider contacting me
via <a href="mailto:tamius.han@gmail.com" target="_blank">email</a> or <a href="https://www.reddit.com/message/compose?to=xternal7" target="_blank">reddit</a>.
</li>
<li>Fixed a bug where user added actions would not be removable the nice way.</li>
</ul>
</div>
</template>