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) {
var http = "http://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
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();