From f3137268635dbec1de8016462a03db201376dad2 Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Sun, 4 Nov 2018 18:31:56 -0600 Subject: [PATCH] Convirted to be mostly ES6 compliant. --- src/scripts/background.js | 2 +- src/scripts/betterYoutube.js | 50 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/scripts/background.js b/src/scripts/background.js index 47170cf..503bca5 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -1,4 +1,4 @@ -function handleUpdated(tabId, changeInfo, tabInfo) { +const handleUpdated = (tabId, changeInfo, tabInfo) => { if (changeInfo.url) { var http = "http://www.youtube.com/watch?v="; var https = "https://www.youtube.com/watch?v="; diff --git a/src/scripts/betterYoutube.js b/src/scripts/betterYoutube.js index c5575ed..7c20fce 100644 --- a/src/scripts/betterYoutube.js +++ b/src/scripts/betterYoutube.js @@ -1,17 +1,17 @@ -function betterYoutubePlus() { +const betterYoutubePlus = () => { // Declare variables - var slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems - var ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images + let slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems + let ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg; - var mastHead, mainContentArea, playerWindow; // Youtube Player container - var video, containerOfPlyrWndow, poppedContainer; // Video accessor - var vdoPlyrAtts; // Player attributes - var part, videoSlug, temp; // Image part - var count = 0; + let mastHead, mainContentArea, playerWindow; // Youtube Player container + let video, containerOfPlyrWndow, poppedContainer; // Video accessor + let vdoPlyrAtts; // Player attributes + let part, videoSlug, temp; // Image part + let count = 0; - function preSetupProc() { + const preSetupProc = () => { video = document.getElementsByTagName("video")[0]; // Video Controler slugInputTag = document.createElement("INPUT"); slugInputTag.id = "slugCopyZone"; @@ -27,7 +27,7 @@ function betterYoutubePlus() { slugInputTag.value = vdoPlyrAtts.slice(32, 32+11); } - function setupProc() { + const setupProc = () => { poppedContainer = document.createElement("DIV"); ytThumbImgMenu = document.createElement("DIV"); ytEnhancerMenu = document.createElement("DIV"); @@ -104,7 +104,7 @@ function betterYoutubePlus() { } // Functions - function showThumbImageVew(e) { + const showThumbImageVew = (e) => { videoSlug = video.baseURI.slice(32, 32+11); // Used for setting up thumbnails if (ytThumbImgMenu.style.display == "block") { @@ -135,7 +135,7 @@ function betterYoutubePlus() { return; } - function setLoop(e) { + const setLoop = (e) => { if (video.loop == false) { video.loop = true; ytLoopBttn.title = "Stop Loop..."; @@ -148,8 +148,8 @@ function betterYoutubePlus() { return; } - function toggleFloat() { - var playerWindow = document.getElementById("movie_player"); // Actual player + const toggleFloat = () => { + let playerWindow = document.getElementById("movie_player"); // Actual player if(poppedContainer.style.display == "none"){ setVideoStyle("auto", "auto", "50%"); @@ -164,8 +164,8 @@ function betterYoutubePlus() { } } - function setVideoStyle(w, h, pr) { - var elm = document.getElementsByClassName("ytp-right-controls")[0]; + const setVideoStyle = (w, h, pr) => { + let elm = document.getElementsByClassName("ytp-right-controls")[0]; video.style.width = w; video.style.height = h; elm.style.paddingRight = pr; @@ -173,8 +173,8 @@ function betterYoutubePlus() { console.log(video.style); } - function manageVolume(e) { - var delta; + const manageVolume = (e) => { + let delta; e.preventDefault(); // Keep page from scrolling while in video area // Detect scroll direction @@ -183,8 +183,8 @@ function betterYoutubePlus() { if (delta > 0) video.volume += 0.05; else if (delta < 0) video.volume -= 0.05; } - function dragVideo(elmnt) { - var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; + const dragVideo = (elmnt) => { + let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; elmnt.onmousedown = dragMouseDown; function dragMouseDown(e) { @@ -198,7 +198,7 @@ function betterYoutubePlus() { document.onmousemove = elementDrag; } - function elementDrag(e) { + const elementDrag = (e) => { e = e || window.event; pauseEvent(e); // calculate the new cursor position: @@ -211,13 +211,13 @@ function betterYoutubePlus() { elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } - function closeDragElement(e) { + const closeDragElement = (e) => { // stop moving when mouse button is released: document.onmouseup = null; document.onmousemove = null; } - function pauseEvent(e) { + const pauseEvent = (e) => { if(e.stopPropagation) e.stopPropagation(); if(e.preventDefault) e.preventDefault(); e.cancelBubble = true; @@ -226,9 +226,9 @@ function betterYoutubePlus() { } } - function checkPg() { + const checkPg = () => { if (!document.getElementById("enhancerMenuIDRef")) { - var existCondition = setInterval(function() { + let existCondition = setInterval(function() { if (document.getElementById("masthead-container")) { clearInterval(existCondition); preSetupProc();