-
Notifications
You must be signed in to change notification settings - Fork 1
/
AmazonVideoZoom.user.js
39 lines (35 loc) · 1.07 KB
/
AmazonVideoZoom.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==UserScript==
// @name Amazon Video Zoom
// @namespace amazon.tld
// @version 1.1
// @description Pressing F2 removes unnecessary black bars by zooming in. Especially useful with 21:9 monitors.
// @include https://www.amazon.tld/*
// @grant none
// ==/UserScript==
//
// License: CC0 1.0 Universal (Public Domain)
// https://creativecommons.org/publicdomain/zero/1.0/
//
// Or: http://unlicense.org
//
var toggleZoom = function () {
// Matches all childs: #videoContainer_xyz > video:nth-child(n)
var videos = document.querySelectorAll('div[id^=videoContainer_] > video:nth-child(n)');
if (this.zoomed) {
[].forEach.call(videos, function (video) {
video.style.removeProperty('object-fit');
});
this.zoomed = false;
} else {
[].forEach.call(videos, function (video) {
video.setAttribute('style', ';object-fit:cover;');
});
this.zoomed = true;
}
};
document.onkeydown = function (event) {
// 113 = F2 Key
if (event.keyCode == 113) {
toggleZoom();
}
};