summaryrefslogtreecommitdiff
path: root/viewtube.js
diff options
context:
space:
mode:
authorArun Isaac2017-07-06 20:04:32 +0530
committerArun Isaac2017-07-06 21:10:38 +0530
commitf60a3bed956c0f71e8684fd9915f9c3c5aba90b5 (patch)
tree79aefe608d2617a8fc0a323cdc50029ca1d2a5d6 /viewtube.js
parente95068d4b89801ec4f174840bbc91ebc3b3c3273 (diff)
downloadyoutube-noscript-shim-f60a3bed956c0f71e8684fd9915f9c3c5aba90b5.tar.gz
youtube-noscript-shim-f60a3bed956c0f71e8684fd9915f9c3c5aba90b5.tar.lz
youtube-noscript-shim-f60a3bed956c0f71e8684fd9915f9c3c5aba90b5.zip
Remove explicit player size detection.
* viewtube.js (createMyPlayer, playMyVideo): Remove player size (width, height, margin) settings. (ytSizes): Remove function. Remove invocations of `ytSizes'.
Diffstat (limited to 'viewtube.js')
-rw-r--r--viewtube.js71
1 files changed, 2 insertions, 69 deletions
diff --git a/viewtube.js b/viewtube.js
index 86c9ecf..2a0f7b0 100644
--- a/viewtube.js
+++ b/viewtube.js
@@ -131,24 +131,13 @@
function onGot(item) {
Object.assign(option, item);
- /* Player Settings */
- player['panelHeight'] = 18;
- player['panelPadding'] = 2;
-
/* The Panel */
- var panelWidth = player['playerWidth'] - player['panelPadding'] * 2;
player['playerPanel'] = createMyElement('div', '', '', '', '');
- styleMyElement(player['playerPanel'], {width: panelWidth + 'px', height: player['panelHeight'] + 'px', padding: player['panelPadding'] + 'px', backgroundColor: 'inherit', textAlign: 'center'});
player['playerWindow'].appendChild(player['playerPanel']);
- /* Panel Items */
- var panelItemBorder = 1;
- var panelItemHeight = player['panelHeight'] - panelItemBorder * 2;
-
/* Panel Video Menu */
player['videoMenu'] = createMyElement('select', '', 'change', '', 'video');
player['videoMenu'].title = '{Videos: select the video format for playback}';
- styleMyElement(player['videoMenu'], {width: '200px', height: panelItemHeight + 'px', border: '1px solid transparent', padding: '0px', display: 'inline', backgroundColor: 'inherit', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
player['playerPanel'].appendChild(player['videoMenu']);
for (var videoCode in player['videoList']) {
player['videoItem'] = createMyElement('option', videoCode, '', '', '');
@@ -160,10 +149,7 @@
}
/* The Content */
- player['contentWidth'] = player['playerWidth'];
- player['contentHeight'] = player['playerHeight'] - player['panelHeight'] - player['panelPadding'] * 2;
player['playerContent'] = createMyElement('div', '', '', '', '');
- styleMyElement(player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', position: 'relative', color: '#AD0000', backgroundColor: '#000000', fontSize: '14px', fontWeight: 'bold', textAlign: 'center'});
player['playerWindow'].appendChild(player['playerContent']);
/* Play My Video */
@@ -227,10 +213,7 @@
playDASHwithHTML5();
else
player['contentVideo'] = createMyElement('video', player['videoList'][player['videoPlay']], '', '', '');
- player['contentVideo'].width = player['contentWidth'];
- player['contentVideo'].height = player['contentHeight'];
player['contentVideo'].poster = player['videoThumb'];
- styleMyElement(player['contentVideo'], {position: 'relative', width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
player['playerContent'].appendChild(player['contentVideo']);
}
@@ -381,42 +364,6 @@
}
}
- /* Player Size */
- var ytSidebarMarginNormal = 382;
- var ytSidebarWindow = document.querySelector("#watch7-sidebar");
- if (ytSidebarWindow) {
- var ytSidebarWindowStyle = ytSidebarWindow.currentStyle || window.getComputedStyle(ytSidebarWindow);
- if (ytSidebarWindowStyle) ytSidebarMarginNormal = -12 + parseInt(ytSidebarWindowStyle.marginTop.replace('px', ''));
- styleMyElement(ytSidebarWindow, {marginTop: ytSidebarMarginNormal + 'px'});
- }
- var ytPlayerWidth, ytPlayerHeight;
- var ytPlayerWideWidth, ytPlayerWideHeight;
- var ytSidebarMarginWide;
- var ytScreenWidth, ytScreenHeight;
- function ytSizes() {
- ytScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
- ytScreenHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
- if (ytScreenWidth >= 1720 && ytScreenHeight >= 980) {
- ytPlayerWidth = 1280;
- ytPlayerHeight = 742;
- ytPlayerWideWidth = 1706;
- ytPlayerWideHeight = 982;
- }
- else if (ytScreenWidth >= 1294 && ytScreenHeight >= 630) {
- ytPlayerWidth = 854;
- ytPlayerHeight = 502;
- ytPlayerWideWidth = 1280;
- ytPlayerWideHeight = 742;
- }
- else {
- ytPlayerWidth = 640;
- ytPlayerHeight = 382;
- ytPlayerWideWidth = 1066;
- ytPlayerWideHeight = 622;
- }
- ytSidebarMarginWide = ytPlayerHeight + ytSidebarMarginNormal;
- }
-
/* Get Player Window */
var ytPlayerWindow = document.querySelector("#player");
if (!ytPlayerWindow) {
@@ -475,9 +422,6 @@
else ytVideosContent = ytVideosAdaptiveFmts;
}
- /* Get Sizes */
- ytSizes();
-
function removeElements (selector) {
document.querySelectorAll(selector).forEach(function (element) { element.remove(); });
}
@@ -491,16 +435,12 @@
/* Playlist */
var ytPlaylist = document.querySelector("#player-playlist");
if (ytPlaylist) {
- styleMyElement(ytPlaylist, {marginLeft: '-' + ytPlayerWidth + 'px'});
var ytPlaceholderPlaylist = document.querySelector("#placeholder-playlist");
if (ytPlaceholderPlaylist) ytPlaceholderPlaylist.appendChild(ytPlaylist);
}
/* My Player Window */
- var myPlayerWindow = createMyElement('div', '', '', '', '');
- styleMyElement(myPlayerWindow, {position: 'relative', width: ytPlayerWidth + 'px', height: ytPlayerHeight + 'px', backgroundColor: '#FFFFFF'});
- modifyMyElement(ytPlayerWindow, 'div', '', false, true);
- ytPlayerWindow.appendChild(myPlayerWindow);
+ var myPlayerWindow = document.querySelector("#player-api");
/* Create Player */
var ytDefaultVideo = 'Low Definition MP4';
@@ -510,14 +450,7 @@
'playerWindow': myPlayerWindow,
'videoList': ytVideoList,
'videoPlay': ytDefaultVideo,
- 'videoThumb': ytVideoThumb,
- 'playerWidth': ytPlayerWidth,
- 'playerHeight': ytPlayerHeight,
- 'playerWideWidth': ytPlayerWideWidth,
- 'playerWideHeight': ytPlayerWideHeight,
- 'sidebarWindow': ytSidebarWindow,
- 'sidebarMarginNormal': ytSidebarMarginNormal,
- 'sidebarMarginWide': ytSidebarMarginWide
+ 'videoThumb': ytVideoThumb
};
option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
option['containers'] = ['MP4', 'WebM', 'FLV', '3GP', 'Any'];