Merge branch 'master' into stable

This commit is contained in:
Tamius Han 2020-05-17 02:30:35 +02:00
commit 59e193b592
22 changed files with 172 additions and 47 deletions

41
.vscode/settings.json vendored
View File

@ -1,30 +1,71 @@
{ {
"cSpell.words": [ "cSpell.words": [
"PILLARBOX",
"PILLARBOXED",
"aard",
"ardetector", "ardetector",
"autodetect",
"autodetection", "autodetection",
"beforeunload",
"blackbar", "blackbar",
"blackbars",
"blackframe", "blackframe",
"canvas", "canvas",
"com",
"comms", "comms",
"csui",
"decycle", "decycle",
"disneyplus",
"equalish", "equalish",
"fuckup",
"gfycat",
"gmail",
"guardline",
"han",
"iframe",
"imgur",
"insta", "insta",
"letterboxed",
"manjaro",
"minification", "minification",
"nogrow",
"noshrink",
"outro",
"polyfill",
"recursing", "recursing",
"reddit", "reddit",
"rescan", "rescan",
"resizer", "resizer",
"scrollbar",
"shitiness",
"smallcaps",
"suboption",
"tabitem",
"tablist",
"tamius",
"textbox", "textbox",
"ultrawidify",
"unmark",
"unmarking",
"unshift",
"uwid",
"uwui",
"videodata", "videodata",
"vids",
"vuejs",
"vuex", "vuex",
"webextension",
"webextensions",
"youtube" "youtube"
], ],
"cSpell.ignoreWords": [ "cSpell.ignoreWords": [
"abcdefghijklmnopqrstuvwxyz",
"autoar", "autoar",
"cheight", "cheight",
"cwidth", "cwidth",
"fcstart", "fcstart",
"fctime", "fctime",
"legacycd",
"ncol", "ncol",
"nrow", "nrow",
"tickrate", "tickrate",

View File

@ -13,7 +13,12 @@ QoL improvements for me:
* logging: allow to enable logging at will and export said logs to a file * logging: allow to enable logging at will and export said logs to a file
### v4.4.7 (Current) ### v4.4.8 (Current)
* Fixed the bug where on pages with more than one video, the list of available videos in the extension popup wouldn't remove videos that are no longer displayed on site. This resulted in extension listing videos that were no longer on the page. Reboot or navigation would also not clear the list if navigating between various pages on the same host.
* Fixed the chrome-only bug where on sites with more than one video, the number wouldn't get hidden when the extension popup closed.
### v4.4.7
* Removed unnecessary font files and image files from the package. * Removed unnecessary font files and image files from the package.
* LoggerUI is now functional. * LoggerUI is now functional.

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "ultravidify", "name": "ultravidify",
"version": "4.4.7", "version": "4.4.8",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "ultravidify", "name": "ultrawidify",
"version": "4.4.7", "version": "4.4.8",
"description": "Aspect ratio fixer for youtube and other sites, with automatic aspect ratio detection. Supports ultrawide and other ratios.", "description": "Aspect ratio fixer for youtube and other sites, with automatic aspect ratio detection. Supports ultrawide and other ratios.",
"author": "Tamius Han <tamius.han@gmail.com>", "author": "Tamius Han <tamius.han@gmail.com>",
"scripts": { "scripts": {

View File

@ -8,6 +8,7 @@ const BrowserDetect = {
chrome: process.env.BROWSER === 'chrome', chrome: process.env.BROWSER === 'chrome',
edge: process.env.BROWSER === 'edge', edge: process.env.BROWSER === 'edge',
processEnvBrowser: process.env.BROWSER, processEnvBrowser: process.env.BROWSER,
processEnvChannel: process.env.CHANNEL,
} }
if (process.env.CHANNEL !== 'stable') { if (process.env.CHANNEL !== 'stable') {

View File

@ -351,7 +351,7 @@ const ExtensionConfPatch = [
'100%' '100%'
] ]
} }
// 'width': true // this would prevent aard from runing if <video> had a 'width' property in style, regardless of value // 'width': true // this would prevent aard from running if <video> had a 'width' property in style, regardless of value
// could also be an empty object, in theory. // could also be an empty object, in theory.
} }
} }

View File

@ -50,7 +50,7 @@ var ExtensionConf = {
// component. Average intensity is normalized to where 0 is black and 1 is biggest value for // component. Average intensity is normalized to where 0 is black and 1 is biggest value for
// that component. If sum of differences between normalized average intensity and normalized // that component. If sum of differences between normalized average intensity and normalized
// component varies more than this % between color components, we can afford to use less strict // component varies more than this % between color components, we can afford to use less strict
// cummulative treshold. // cumulative threshold.
cumulativeThresholdLax: 1600, cumulativeThresholdLax: 1600,
cumulativeThresholdStrict: 2560,// if we add values of all pixels together and get more than this, the frame is bright enough. cumulativeThresholdStrict: 2560,// if we add values of all pixels together and get more than this, the frame is bright enough.
// (note: blackframe is 16x9 px -> 144px total. cumulative threshold can be reached fast) // (note: blackframe is 16x9 px -> 144px total. cumulative threshold can be reached fast)
@ -64,7 +64,7 @@ var ExtensionConf = {
threshold: 16, // if pixel is darker than the sum of black level and this value, we count it as black threshold: 16, // if pixel is darker than the sum of black level and this value, we count it as black
// on 0-255. Needs to be fairly high (8 might not cut it) due to compression // on 0-255. Needs to be fairly high (8 might not cut it) due to compression
// artifacts in the video itself // artifacts in the video itself
frameThreshold: 4, // treshold, but when doing blackframe test frameThreshold: 4, // threshold, but when doing blackframe test
imageThreshold: 16, // in order to detect pixel as "not black", the pixel must be brighter than imageThreshold: 16, // in order to detect pixel as "not black", the pixel must be brighter than
// the sum of black level, threshold and this value. // the sum of black level, threshold and this value.
gradientThreshold: 2, // When trying to determine thickness of the black bars, we take 2 values: position of gradientThreshold: 2, // When trying to determine thickness of the black bars, we take 2 values: position of
@ -72,7 +72,7 @@ var ExtensionConf = {
// brighter than our image threshold. If positions are more than this many pixels apart, // brighter than our image threshold. If positions are more than this many pixels apart,
// we assume we aren't looking at letterbox and thus don't correct the aspect ratio. // we assume we aren't looking at letterbox and thus don't correct the aspect ratio.
gradientSampleSize: 16, // How far do we look to find the gradient gradientSampleSize: 16, // How far do we look to find the gradient
maxGradient: 6, // if two neighbouring pixels in gradientSampleSize differ by more than this, then we aren't maxGradient: 6, // if two neighboring pixels in gradientSampleSize differ by more than this, then we aren't
// looking at a gradient // looking at a gradient
gradientNegativeTreshold: -2, gradientNegativeTreshold: -2,
gradientMaxSD: 6, // reserved for future use gradientMaxSD: 6, // reserved for future use
@ -173,7 +173,7 @@ var ExtensionConf = {
// Polje 'shortcut' je tabela, če se slučajno lotimo kdaj delati choordov. // Polje 'shortcut' je tabela, če se slučajno lotimo kdaj delati choordov.
actions: [{ actions: [{
name: 'Trigger automatic detection', // name displayed in settings name: 'Trigger automatic detection', // name displayed in settings
label: 'Automatic', // name displayed in ui (can be overriden in scope/playerUi) label: 'Automatic', // name displayed in ui (can be overridden in scope/playerUi)
cmd: [{ cmd: [{
action: 'set-ar', action: 'set-ar',
arg: AspectRatio.Automatic, arg: AspectRatio.Automatic,
@ -1047,7 +1047,7 @@ var ExtensionConf = {
'100%' '100%'
] ]
} }
// 'width': true // this would prevent aard from runing if <video> had a 'width' property in style, regardless of value // 'width': true // this would prevent aard from running if <video> had a 'width' property in style, regardless of value
// could also be an empty object, in theory. // could also be an empty object, in theory.
} }
} }
@ -1079,7 +1079,7 @@ var ExtensionConf = {
'100%' '100%'
] ]
} }
// 'width': true // this would prevent aard from runing if <video> had a 'width' property in style, regardless of value // 'width': true // this would prevent aard from running if <video> had a 'width' property in style, regardless of value
// could also be an empty object, in theory. // could also be an empty object, in theory.
} }
} }

View File

@ -212,7 +212,7 @@ class CommsServer {
this.sendToAll(message); this.sendToAll(message);
return; return;
} }
[tab, frame] = tab.split('-') [tab, frame] = frame.split('-');
} }
this.logger.log('info', 'comms', `%c[CommsServer::sendToFrame] attempting to send message to tab ${tab}, frame ${frame}`, "background: #dda; color: #11D", message); this.logger.log('info', 'comms', `%c[CommsServer::sendToFrame] attempting to send message to tab ${tab}, frame ${frame}`, "background: #dda; color: #11D", message);
@ -328,6 +328,12 @@ class CommsServer {
this.handleMessage(message, sender, sendResponse); this.handleMessage(message, sender, sendResponse);
} }
// chrome shitiness mitigation
sendUnmarkPlayer(message) {
this.logger.log('info', 'comms', '[CommsServer.js::sendUnmarkPlayer] Chrome is a shit browser that doesn\'t do port.postMessage() in unload events, so we have to resort to inelegant hacks. If you see this, then the workaround method works.');
this.processReceivedMessage(message, this.popupPort);
}
} }
export default CommsServer; export default CommsServer;

View File

@ -178,7 +178,7 @@ class PageInfo {
if (this.readOnly) { if (this.readOnly) {
// in lite mode, we're done. This is all the info we want, but we want to actually start doing // in lite mode, we're done. This is all the info we want, but we want to actually start doing
// things that interfere with the website. We still want to be runnig a rescan, tho. // things that interfere with the website. We still want to be running a rescan, tho.
if(rescanReason == RescanReason.PERIODIC){ if(rescanReason == RescanReason.PERIODIC){
this.scheduleRescan(RescanReason.PERIODIC); this.scheduleRescan(RescanReason.PERIODIC);
@ -237,12 +237,28 @@ class PageInfo {
// if we're left without videos on the current page, we unregister the page. // if we're left without videos on the current page, we unregister the page.
// if we have videos, we call register. // if we have videos, we call register.
if (this.comms) { if (this.comms) {
if (this.videos.length != oldVideoCount) { // only if number of videos changed, tho // We used to send "register video" requests only on the first load, or if the number of
if (this.videos.length > 0) { // videos on the page has changed. However, since Chrome Web Store started to require every
this.comms.registerVideo({host: window.location.host, location: window.location}); // extension requiring "broad permissions" to undergo manual review
} else { // ... and since Chrome Web Store is known for taking their sweet ass time reviewing extensions,
this.comms.unregisterVideo({host: window.location.host, location: window.location}); // with review times north of an entire fucking month
} // ... and since the legacy way of checking whether our frames-with-videos cache in background
// script contains any frames that no longer exist required us to use webNavigation.getFrame()/
// webNavigation.getAllFrames(), which requires a permission that triggers a review.
//
// While the extension uses some other permissions that trigger manual review, it's said that
// less is better / has a positive effect on your manual review times ... So I guess we'll do
// things in the less-than-optimal. more-than-retarded way.
//
// no but honestly fuck Chrome.
// if (this.videos.length != oldVideoCount) {
// }
if (this.videos.length > 0) {
this.comms.registerVideo({host: window.location.host, location: window.location});
} else {
this.comms.unregisterVideo({host: window.location.host, location: window.location});
} }
} }
@ -252,7 +268,7 @@ class PageInfo {
// našli ob naslednjem preiskovanju // našli ob naslednjem preiskovanju
// //
// if we encounter a fuckup, we can assume that no videos were found on the page. We destroy all videoData // if we encounter a fuckup, we can assume that no videos were found on the page. We destroy all videoData
// objects to prevent multiple initalization (which happened, but I don't know why). No biggie if we destroyed // objects to prevent multiple initialization (which happened, but I don't know why). No biggie if we destroyed
// videoData objects in error — they'll be back in the next rescan // videoData objects in error — they'll be back in the next rescan
this.logger.log('error', 'debug', "rescan error: — destroying all videoData objects",e); this.logger.log('error', 'debug', "rescan error: — destroying all videoData objects",e);
for (const v of this.videos) { for (const v of this.videos) {
@ -567,7 +583,7 @@ class PageInfo {
} }
setKeyboardShortcutsEnabled(state) { setKeyboardShortcutsEnabled(state) {
this.actionHandler.setKeybordLocal(state); this.actionHandler.setKeyboardLocal(state);
} }
setArPersistence(persistenceMode) { setArPersistence(persistenceMode) {

View File

@ -129,7 +129,7 @@ class PlayerData {
try { try {
this.doPeriodicPlayerElementChangeCheck(); this.doPeriodicPlayerElementChangeCheck();
} catch (e) { } catch (e) {
console.error('[playerdata::legacycd] this message is pretty high on the list of messages you shouldnt see', e); console.error('[PlayerData::legacycd] this message is pretty high on the list of messages you shouldnt see', e);
} }
} }
} }
@ -187,8 +187,9 @@ class PlayerData {
} }
unmarkPlayer() { unmarkPlayer() {
this.logger.log('info', 'debug', "[PlayerData::unmarkPlayer] unmarking player!") this.logger.log('info', 'debug', "[PlayerData::unmarkPlayer] unmarking player!", {playerIdElement: this.playerIdElement});
if (this.playerIdElement) { if (this.playerIdElement) {
this.playerIdElement.innerHTML = '';
this.playerIdElement.remove(); this.playerIdElement.remove();
} }
this.playerIdElement = undefined; this.playerIdElement = undefined;

View File

@ -76,7 +76,7 @@ class Stretcher {
// poznamo. Torej jih moramo računati. // poznamo. Torej jih moramo računati.
// //
// //
// video.videoWidht and video.videoHeight describe the size of the video file. // video.videoWidth and video.videoHeight describe the size of the video file.
// Size of the video file can be different than the size of the <video> tag. // Size of the video file can be different than the size of the <video> tag.
// This can leave us with the following situation: // This can leave us with the following situation:
// * Video resolution is 850x480-ish (as reported by videoWidth and videoHeight) // * Video resolution is 850x480-ish (as reported by videoWidth and videoHeight)
@ -103,7 +103,7 @@ class Stretcher {
const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight; const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
const playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height; const playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
const squezeFactor = this.fixedStretchRatio / videoAr; const squeezeFactor = this.fixedStretchRatio / videoAr;
// Whether squeezing happens on X or Y axis depends on whether required AR is wider or narrower than // 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 // the player, in which the video is displayed
@ -115,13 +115,13 @@ postCropStretchFactors: x=${postCropStretchFactors.xFactor} y=${postCropStretchF
fixedStretchRatio: ${this.fixedStretchRatio} fixedStretchRatio: ${this.fixedStretchRatio}
videoAr: ${videoAr} videoAr: ${videoAr}
playerAr: ${playerAr} playerAr: ${playerAr}
squeezeFactor: ${squezeFactor}`, '\nvideo', this.conf.video); squeezeFactor: ${squeezeFactor}`, '\nvideo', this.conf.video);
if (this.fixedStretchRatio < playerAr) { if (this.fixedStretchRatio < playerAr) {
postCropStretchFactors.xFactor *= squezeFactor; postCropStretchFactors.xFactor *= squeezeFactor;
} else { } else {
postCropStretchFactors.yFactor *= squezeFactor; postCropStretchFactors.yFactor *= squeezeFactor;
} }
this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we'll apply:\npostCropStretchFactors: x=${postCropStretchFactors.x} y=${postCropStretchFactors.y}`); this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we'll apply:\npostCropStretchFactors: x=${postCropStretchFactors.x} y=${postCropStretchFactors.y}`);

View File

@ -173,14 +173,11 @@ class UWServer {
} }
if (this.videoTabs[sender.tab.id]) { if (this.videoTabs[sender.tab.id]) {
if (this.videoTabs[sender.tab.id].frames[sender.frameId]) { this.videoTabs[sender.tab.id].frames[sender.frameId] = {
return; // existing value is fine, no need to act id: sender.frameId,
} else { host: frameHostname,
this.videoTabs[sender.tab.id].frames[sender.frameId] = { url: sender.url,
id: sender.frameId, registerTime: Date.now(),
host: frameHostname,
url: sender.url
}
} }
} else { } else {
this.videoTabs[sender.tab.id] = { this.videoTabs[sender.tab.id] = {
@ -192,7 +189,8 @@ class UWServer {
this.videoTabs[sender.tab.id].frames[sender.frameId] = { this.videoTabs[sender.tab.id].frames[sender.frameId] = {
id: sender.frameId, id: sender.frameId,
host: frameHostname, host: frameHostname,
url: sender.url url: sender.url,
registerTime: Date.now(),
} }
} }
@ -290,6 +288,25 @@ class UWServer {
} }
if (this.videoTabs[ctab.id]) { if (this.videoTabs[ctab.id]) {
// if video is older than PageInfo's video rescan period (+ 4000ms of grace),
// we clean it up from videoTabs[tabId].frames array.
const ageLimit = Date.now() - this.settings.active.pageInfo.timeouts.rescan - 4000;
console.log("videoTabs[tabId]:", this.videoTabs[ctab.id])
try {
for (const key in this.videoTabs[ctab.id].frames) {
if (this.videoTabs[ctab.id].frames[key].registerTime < ageLimit) {
delete this.videoTabs[ctab.id].frames[key];
}
}
} catch (e) {
// something went wrong. There's prolly no frames.
return {
host: this.extractHostname(ctab.url),
frames: [],
selected: this.selectedSubitem
}
}
return { return {
...this.videoTabs[ctab.id], ...this.videoTabs[ctab.id],
host: this.extractHostname(ctab.url), host: this.extractHostname(ctab.url),
@ -305,6 +322,15 @@ class UWServer {
selected: this.selectedSubitem selected: this.selectedSubitem
} }
} }
// chrome shitiness mitigation
sendUnmarkPlayer(message) {
this.comms.sendUnmarkPlayer(message);
}
} }
var server = new UWServer(); var server = new UWServer();
window.sendUnmarkPlayer = (message) => {
server.sendUnmarkPlayer(message)
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
src/icons/uw-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
src/icons/uw-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/icons/uw-64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "Ultrawidify", "name": "Ultrawidify",
"description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.", "description": "Removes black bars on ultrawide videos and offers advanced options to fix aspect ratio.",
"version": "4.4.7.2", "version": "4.4.8",
"applications": { "applications": {
"gecko": { "gecko": {
"id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}" "id": "{cf02b1a7-a01a-4e37-a609-516a283f1ed3}"
@ -29,6 +29,7 @@
}], }],
"background": { "background": {
"persistent": true,
"scripts": [ "scripts": [
"ext/uw-bg.js" "ext/uw-bg.js"
] ]

View File

@ -2,8 +2,11 @@
<div v-if="settingsInitialized" <div v-if="settingsInitialized"
class="popup flex flex-column no-overflow" class="popup flex flex-column no-overflow"
> >
<div class="header flex-row flex-nogrow flex-noshrink"> <div class="header flex-row flex-nogrow flex-noshrink relative">
<span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small> <span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small>
<div class="absolute channel-info" v-if="BrowserDetect.processEnvChannel !== 'stable'">
Build channel: {{BrowserDetect.processEnvChannel}}
</div>
</div> </div>
<div class="flex flex-row body no-overflow flex-grow"> <div class="flex flex-row body no-overflow flex-grow">
@ -202,6 +205,7 @@ export default {
videoTabDisabled: false, videoTabDisabled: false,
canShowVideoTab: {canShow: true, warning: true}, canShowVideoTab: {canShow: true, warning: true},
showWhatsNew: false, showWhatsNew: false,
BrowserDetect: BrowserDetect,
} }
}, },
async created() { async created() {
@ -223,6 +227,12 @@ export default {
cmd: 'unmark-player', cmd: 'unmark-player',
forwardToAll: true, forwardToAll: true,
}); });
if (BrowserDetect.chrome) {
chrome.extension.getBackgroundPage().sendUnmarkPlayer({
cmd: 'unmark-player',
forwardToAll: true,
});
}
}); });
// get info about current site from background script // get info about current site from background script
@ -240,6 +250,7 @@ export default {
DefaultSettingsPanel, DefaultSettingsPanel,
PerformancePanel, PerformancePanel,
Debug, Debug,
BrowserDetect,
AboutPanel, AboutPanel,
Donate, Donate,
SiteDetailsPanel, SiteDetailsPanel,
@ -344,7 +355,7 @@ export default {
// Extension global disabled show 'extension settings' // Extension global disabled show 'extension settings'
// Extension site disabled, no embedded videos show 'site settings' // Extension site disabled, no embedded videos show 'site settings'
// Extension site disabled, embedded videos from non-blacklisted hosts show video settings // Extension site disabled, embedded videos from non-blacklisted hosts show video settings
// Extension site enabled show vido settings // Extension site enabled show video settings
// note: this if statement is ever so slightly unnecessary // note: this if statement is ever so slightly unnecessary
if (! this.settings.canStartExtension('@global')) { if (! this.settings.canStartExtension('@global')) {
@ -582,4 +593,17 @@ html, body {
// width: 800px; // width: 800px;
height: 600px; height: 600px;
} }
.relative {
position: relative;
}
.absolute {
position: absolute;
}
.channel-info {
height: 0px;
right: 1.5rem;
bottom: 0.85rem;
font-size: 0.75rem;
}
</style> </style>

View File

@ -2,14 +2,18 @@
<div> <div>
<h2>What's new</h2> <h2>What's new</h2>
<p>Full changelog for older versions <a href="https://github.com/tamius-han/ultrawidify/blob/master/CHANGELOG.md">is available here</a>.</p> <p>Full changelog for older versions <a href="https://github.com/tamius-han/ultrawidify/blob/master/CHANGELOG.md">is available here</a>.</p>
<p class="label">4.4.7</p> <p class="label">4.4.8</p>
<ul> <ul>
<li><b>[4.4.7.1]</b> CSS fixes</li> <li>
<li><b>[4.4.7.1~2]</b> Delay CSS changes if video dimensions are invalid (attempt to fix youtube alignment problems Fixed the bug where on pages with more than one video, the list of available videos in the extension popup
that appear in certain circumstances). 4.4.7.2 increased number of retries. wouldn't remove videos that are no longer displayed on site. This resulted in extension listing videos that
were no longer on the page. Reboot or navigation would also not clear the list if navigating between various
pages on the same host.
</li>
<li>
Fixed the chrome-only bug where on sites with more than one video, the number wouldn't get hidden when the
extension popup closed.
</li> </li>
<li>Removed unnecessary font files and image files from the package.</li>
<li>(For testing/debugging purposes) Logger UI in swatter mode is now somewhat functional and user-friendly.</li>
</ul> </ul>
</div> </div>
</template> </template>