Convirted to be mostly ES6 compliant.

This commit is contained in:
Maxim Stewart 2018-11-04 18:31:56 -06:00
parent 1cd54e96bb
commit f313726863
2 changed files with 26 additions and 26 deletions

View File

@ -1,4 +1,4 @@
function handleUpdated(tabId, changeInfo, tabInfo) { const handleUpdated = (tabId, changeInfo, tabInfo) => {
if (changeInfo.url) { if (changeInfo.url) {
var http = "http://www.youtube.com/watch?v="; var http = "http://www.youtube.com/watch?v=";
var https = "https://www.youtube.com/watch?v="; var https = "https://www.youtube.com/watch?v=";

View File

@ -1,17 +1,17 @@
function betterYoutubePlus() { const betterYoutubePlus = () => {
// Declare variables // Declare variables
var slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems let slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems
var ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images let ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images
ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg; ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg;
var mastHead, mainContentArea, playerWindow; // Youtube Player container let mastHead, mainContentArea, playerWindow; // Youtube Player container
var video, containerOfPlyrWndow, poppedContainer; // Video accessor let video, containerOfPlyrWndow, poppedContainer; // Video accessor
var vdoPlyrAtts; // Player attributes let vdoPlyrAtts; // Player attributes
var part, videoSlug, temp; // Image part let part, videoSlug, temp; // Image part
var count = 0; let count = 0;
function preSetupProc() { const preSetupProc = () => {
video = document.getElementsByTagName("video")[0]; // Video Controler video = document.getElementsByTagName("video")[0]; // Video Controler
slugInputTag = document.createElement("INPUT"); slugInputTag = document.createElement("INPUT");
slugInputTag.id = "slugCopyZone"; slugInputTag.id = "slugCopyZone";
@ -27,7 +27,7 @@ function betterYoutubePlus() {
slugInputTag.value = vdoPlyrAtts.slice(32, 32+11); slugInputTag.value = vdoPlyrAtts.slice(32, 32+11);
} }
function setupProc() { const setupProc = () => {
poppedContainer = document.createElement("DIV"); poppedContainer = document.createElement("DIV");
ytThumbImgMenu = document.createElement("DIV"); ytThumbImgMenu = document.createElement("DIV");
ytEnhancerMenu = document.createElement("DIV"); ytEnhancerMenu = document.createElement("DIV");
@ -104,7 +104,7 @@ function betterYoutubePlus() {
} }
// Functions // Functions
function showThumbImageVew(e) { const showThumbImageVew = (e) => {
videoSlug = video.baseURI.slice(32, 32+11); // Used for setting up thumbnails videoSlug = video.baseURI.slice(32, 32+11); // Used for setting up thumbnails
if (ytThumbImgMenu.style.display == "block") { if (ytThumbImgMenu.style.display == "block") {
@ -135,7 +135,7 @@ function betterYoutubePlus() {
return; return;
} }
function setLoop(e) { const setLoop = (e) => {
if (video.loop == false) { if (video.loop == false) {
video.loop = true; video.loop = true;
ytLoopBttn.title = "Stop Loop..."; ytLoopBttn.title = "Stop Loop...";
@ -148,8 +148,8 @@ function betterYoutubePlus() {
return; return;
} }
function toggleFloat() { const toggleFloat = () => {
var playerWindow = document.getElementById("movie_player"); // Actual player let playerWindow = document.getElementById("movie_player"); // Actual player
if(poppedContainer.style.display == "none"){ if(poppedContainer.style.display == "none"){
setVideoStyle("auto", "auto", "50%"); setVideoStyle("auto", "auto", "50%");
@ -164,8 +164,8 @@ function betterYoutubePlus() {
} }
} }
function setVideoStyle(w, h, pr) { const setVideoStyle = (w, h, pr) => {
var elm = document.getElementsByClassName("ytp-right-controls")[0]; let elm = document.getElementsByClassName("ytp-right-controls")[0];
video.style.width = w; video.style.width = w;
video.style.height = h; video.style.height = h;
elm.style.paddingRight = pr; elm.style.paddingRight = pr;
@ -173,8 +173,8 @@ function betterYoutubePlus() {
console.log(video.style); console.log(video.style);
} }
function manageVolume(e) { const manageVolume = (e) => {
var delta; let delta;
e.preventDefault(); // Keep page from scrolling while in video area e.preventDefault(); // Keep page from scrolling while in video area
// Detect scroll direction // Detect scroll direction
@ -183,8 +183,8 @@ function betterYoutubePlus() {
if (delta > 0) video.volume += 0.05; else if (delta < 0) video.volume -= 0.05; if (delta > 0) video.volume += 0.05; else if (delta < 0) video.volume -= 0.05;
} }
function dragVideo(elmnt) { const dragVideo = (elmnt) => {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
elmnt.onmousedown = dragMouseDown; elmnt.onmousedown = dragMouseDown;
function dragMouseDown(e) { function dragMouseDown(e) {
@ -198,7 +198,7 @@ function betterYoutubePlus() {
document.onmousemove = elementDrag; document.onmousemove = elementDrag;
} }
function elementDrag(e) { const elementDrag = (e) => {
e = e || window.event; e = e || window.event;
pauseEvent(e); pauseEvent(e);
// calculate the new cursor position: // calculate the new cursor position:
@ -211,13 +211,13 @@ function betterYoutubePlus() {
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
} }
function closeDragElement(e) { const closeDragElement = (e) => {
// stop moving when mouse button is released: // stop moving when mouse button is released:
document.onmouseup = null; document.onmouseup = null;
document.onmousemove = null; document.onmousemove = null;
} }
function pauseEvent(e) { const pauseEvent = (e) => {
if(e.stopPropagation) e.stopPropagation(); if(e.stopPropagation) e.stopPropagation();
if(e.preventDefault) e.preventDefault(); if(e.preventDefault) e.preventDefault();
e.cancelBubble = true; e.cancelBubble = true;
@ -226,9 +226,9 @@ function betterYoutubePlus() {
} }
} }
function checkPg() { const checkPg = () => {
if (!document.getElementById("enhancerMenuIDRef")) { if (!document.getElementById("enhancerMenuIDRef")) {
var existCondition = setInterval(function() { let existCondition = setInterval(function() {
if (document.getElementById("masthead-container")) { if (document.getElementById("masthead-container")) {
clearInterval(existCondition); clearInterval(existCondition);
preSetupProc(); preSetupProc();