Initial code publish.

This commit is contained in:
Maxim 2017-12-22 19:44:41 -06:00
parent c9ff432b29
commit daf2a89be1
15 changed files with 360 additions and 0 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# Better Youtube +
Better Youtube + works to improve the Youtube experience by providing quick access to features we'd all like to have from the get-go.
..* It allows quick thumbnail access of the video.
..* It allows setting the loop mode easily.
..* It allows the video to be toggled to fixed or floating with drag functionality.
..* It allows volume control through the mouse-wheel when hovering over the player.
..* It changes the background color to light grey for easier viewing of the pages.
# Version: 1.0.8
This version is the initial released version to the public after testing and getting everything as it should be.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 48 48"
version="1.1"
id="svg3352"
height="48"
width="48">
<defs
id="defs3354" />
<metadata
id="metadata3357">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<text
transform="scale(0.95640531,1.0455818)"
id="text3360"
y="32.654408"
x="25.533363"
style="font-style:normal;font-weight:normal;font-size:23.91013145px;line-height:972.0000267%;font-family:sans-serif;text-align:center;letter-spacing:34.08628464px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="letter-spacing:0px;fill:#ff0000"
y="32.654408"
x="25.533365"
id="tspan3362">BY+</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/icons/floatPlayer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
src/icons/loopFalse.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
src/icons/loopTrue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/icons/thumbnailOff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/icons/thumbnailOn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

38
src/manifest.json Normal file
View File

@ -0,0 +1,38 @@
{
"manifest_version": 2,
"name": "Better Youtube +",
"version": "1.0.8",
"description": "Enhancements for Youtube to have a better experience.",
"applications": {
"gecko": {
"id": "betterYoutube@itdominator.com"
}
},
"permissions": [
"activeTab",
"*://*.youtube.com/*",
"tabs"
],
"icons": {
"48": "icons/betterYoutube.svg",
"96": "icons/betterYoutube.svg"
},
"options_ui": { "page": "pages/options.html" },
"content_scripts": [ {
"matches": ["*://*.youtube.com/watch?v=*"],
"js": ["scripts/jquery-3.2.1.js", "scripts/arrive.js", "scripts/betterYoutube.js"],
"css": ["styles/betterYoutube.css"],
"run_at": "document_end",
"all_frames": true
}],
"web_accessible_resources": [
"icons/*.png"
]
}

27
src/pages/options.html Executable file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="styles/betterYoutube.css"/>
<style media="screen">
p, li { font-size: 160%; }
</style>
</head>
<body>
<p>
Better Youtube + works to improve the Youtube experience by providing quick access to features we'd all like to have from the get-go.
<ul>
<li>It allows quick thumbnail access of the video.</li>
<li>It allows setting the loop mode easily.</li>
<li>It allows the video to be toggled to fixed or floating with drag functionality.</li>
<li>It allows volume control through the mouse-wheel when hovering over the player.</li>
<li>It changes the background color to light grey for easier viewing of the pages.</li>
</ul>
</p>
</body>
</html>

10
src/scripts/arrive.js Normal file
View File

@ -0,0 +1,10 @@
/*
* arrive.js
* v2.4.1
* https://github.com/uzairfarooq/arrive
* MIT licensed
*
* Copyright (c) 2014-2017 Uzair Farooq
*/
var Arrive=function(e,t,n){"use strict";function r(e,t,n){l.addMethod(t,n,e.unbindEvent),l.addMethod(t,n,e.unbindEventWithSelectorOrCallback),l.addMethod(t,n,e.unbindEventWithSelectorAndCallback)}function i(e){e.arrive=f.bindEvent,r(f,e,"unbindArrive"),e.leave=d.bindEvent,r(d,e,"unbindLeave")}if(e.MutationObserver&&"undefined"!=typeof HTMLElement){var o=0,l=function(){var t=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(e,n){return e instanceof HTMLElement&&t.call(e,n)},addMethod:function(e,t,r){var i=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof i?i.apply(this,arguments):n}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var n,r=0;n=e[r];r++)n&&n.callback&&n.callback.call(n.elem,n.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,n,r){for(var i,o=0;i=e[o];o++)n(i,t,r)&&r.push({callback:t.callback,elem:i}),i.childNodes.length>0&&l.checkChildNodesRecursively(i.childNodes,t,n,r)},mergeArrays:function(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r},toElementsArray:function(t){return n===t||"number"==typeof t.length&&t!==e||(t=[t]),t}}}(),c=function(){var e=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return e.prototype.addEvent=function(e,t,n,r){var i={target:e,selector:t,options:n,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},e.prototype.removeEvent=function(e){for(var t,n=this._eventsBucket.length-1;t=this._eventsBucket[n];n--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(n,1);r&&r.length&&(r[0].callback=null)}},e.prototype.beforeAdding=function(e){this._beforeAdding=e},e.prototype.beforeRemoving=function(e){this._beforeRemoving=e},e}(),a=function(t,r){var i=new c,o=this,a={fireOnAttributesModification:!1};return i.beforeAdding(function(n){var i,l=n.target;(l===e.document||l===e)&&(l=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(e){r.call(this,e,n)});var c=t(n.options);i.observe(l,c),n.observer=i,n.me=o}),i.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,n){t=l.mergeArrays(a,t);for(var r=l.toElementsArray(this),o=0;o<r.length;o++)i.addEvent(r[o],e,t,n)},this.unbindEvent=function(){var e=l.toElementsArray(this);i.removeEvent(function(t){for(var r=0;r<e.length;r++)if(this===n||t.target===e[r])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(e){var t,r=l.toElementsArray(this),o=e;t="function"==typeof e?function(e){for(var t=0;t<r.length;t++)if((this===n||e.target===r[t])&&e.callback===o)return!0;return!1}:function(t){for(var i=0;i<r.length;i++)if((this===n||t.target===r[i])&&t.selector===e)return!0;return!1},i.removeEvent(t)},this.unbindEventWithSelectorAndCallback=function(e,t){var r=l.toElementsArray(this);i.removeEvent(function(i){for(var o=0;o<r.length;o++)if((this===n||i.target===r[o])&&i.selector===e&&i.callback===t)return!0;return!1})},this},s=function(){function e(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t}function t(e,t){e.forEach(function(e){var n=e.addedNodes,i=e.target,o=[];null!==n&&n.length>0?l.checkChildNodesRecursively(n,t,r,o):"attributes"===e.type&&r(i,t,o)&&o.push({callback:t.callback,elem:i}),l.callCallbacks(o,t)})}function r(e,t){return l.matchesSelector(e,t.selector)&&(e._id===n&&(e._id=o++),-1==t.firedElems.indexOf(e._id))?(t.firedElems.push(e._id),!0):!1}var i={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};f=new a(e,t);var c=f.bindEvent;return f.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t);var o=l.toElementsArray(this);if(t.existing){for(var a=[],s=0;s<o.length;s++)for(var u=o[s].querySelectorAll(e),f=0;f<u.length;f++)a.push({callback:r,elem:u[f]});if(t.onceOnly&&a.length)return r.call(a[0].elem,a[0].elem);setTimeout(l.callCallbacks,1,a)}c.call(this,e,t,r)},f},u=function(){function e(){var e={childList:!0,subtree:!0};return e}function t(e,t){e.forEach(function(e){var n=e.removedNodes,i=[];null!==n&&n.length>0&&l.checkChildNodesRecursively(n,t,r,i),l.callCallbacks(i,t)})}function r(e,t){return l.matchesSelector(e,t.selector)}var i={};d=new a(e,t);var o=d.bindEvent;return d.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t),o.call(this,e,t,r)},d},f=new s,d=new u;t&&i(t.fn),i(HTMLElement.prototype),i(NodeList.prototype),i(HTMLCollection.prototype),i(HTMLDocument.prototype),i(Window.prototype);var h={};return r(f,h,"unbindAllArrive"),r(d,h,"unbindAllLeave"),h}}(window,"undefined"==typeof jQuery?null:jQuery,void 0);

View File

@ -0,0 +1,173 @@
// Declare variables
var ytThumbImgMenu, ytEnhancerMenu; // Menu systems
var ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images
ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg;
var mastHead, video, mainPlayerWindow, poppedVdoContr; // Video accessor
var mainContentArea; // Youtube Player container
var vdoPlyrAtts; // Player attributes
var part; // Image part
function setupContentandInsert() {
poppedVdoContr = document.createElement("DIV");
ytThumbImgMenu = document.createElement("DIV");
ytEnhancerMenu = document.createElement("DIV");
ytThumbnailBttn = document.createElement("IMG");
ytMaxDefaultImg = document.createElement("IMG");
ytHqDefaultImg = document.createElement("IMG");
ytLoopBttn = document.createElement("IMG");
ytFloatBttn = document.createElement("IMG");
ytAMaxDefaultImg = document.createElement("A");
ytAHqDefaultImg = document.createElement("A");
video = document.getElementsByTagName("video")[0];
mastHead = document.getElementById("masthead");
part = "//i.ytimg.com/vi/";
// Append to nodes as required
mainContentArea = $("ytd-watch");
mainPlayerWindow = $("#player-container").parent();
vdoPlyrAtts = mainContentArea[0].attributes;
ytEnhancerMenu.appendChild(ytThumbnailBttn);
ytEnhancerMenu.appendChild(ytLoopBttn);
ytEnhancerMenu.appendChild(ytFloatBttn);
ytThumbnailBttn.src = browser.extension.getURL("icons/thumbnailOff.png");
ytLoopBttn.src = browser.extension.getURL("icons/loopFalse.png");
ytFloatBttn.src = browser.extension.getURL("icons/floatPlayer.png");
// Insert
document.body.appendChild(poppedVdoContr);
mainContentArea[0].appendChild(ytThumbImgMenu);
mainContentArea[0].appendChild(ytEnhancerMenu);
ytAMaxDefaultImg.appendChild(ytMaxDefaultImg);
ytAHqDefaultImg.appendChild(ytHqDefaultImg);
ytThumbImgMenu.appendChild(ytAMaxDefaultImg);
ytThumbImgMenu.appendChild(ytAHqDefaultImg);
// Set onclick actions
ytThumbnailBttn.addEventListener("click", showThumbImageVew);
ytLoopBttn.addEventListener("click", setLoop);
ytFloatBttn.addEventListener("click", toggleFloat);
video.addEventListener("wheel", manageVolume);
// Dragable window for floating video
dragVideo(poppedVdoContr);
// Set trget of Thumbnails of video
ytAMaxDefaultImg.target = "_blank";
ytAHqDefaultImg.target = "_blank";
// Theming & Apply Styles
ytThumbImgMenu.className = "ytThumbMenuStyle";
ytMaxDefaultImg.className = "thumbImageStyle";
ytHqDefaultImg.className = "thumbImageStyle";
ytEnhancerMenu.className = "ytMenuStyle";
ytThumbnailBttn.className = "imageStyle";
ytLoopBttn.className = "imageStyle";
ytFloatBttn.className = "imageStyle";
poppedVdoContr.id = "draggable";
poppedVdoContr.style.display = "none";
mainContentArea[0].style = "background: #C0C0C0;";
mastHead.style = "background: #C0C0C0;";
}
// Functions
function showThumbImageVew(e) {
if (ytThumbImgMenu.style.display == "block") {
ytThumbImgMenu.style.display = "none";
ytThumbnailBttn.src = browser.extension.getURL("icons/thumbnailOff.png");
} else {
ytAMaxDefaultImg.href = part + vdoPlyrAtts[0].value + "/maxresdefault.jpg";
ytAHqDefaultImg.href = part + vdoPlyrAtts[0].value + "/hqdefault.jpg";
ytMaxDefaultImg.src = part + vdoPlyrAtts[0].value + "/maxresdefault.jpg";
ytHqDefaultImg.src = part + vdoPlyrAtts[0].value + "/hqdefault.jpg";
ytThumbnailBttn.src = browser.extension.getURL("icons/thumbnailOn.png");
ytThumbImgMenu.style.display = "block";
}
return;
}
function setLoop(e) {
if (video.loop == false) {
video.loop = true;
ytLoopBttn.src = browser.extension.getURL("icons/loopTrue.png");
} else {
video.loop = false;
ytLoopBttn.src = browser.extension.getURL("icons/loopFalse.png");
}
return;
}
function toggleFloat() {
playerWindow = document.getElementById("player-container");
if(poppedVdoContr.style.display == "none"){
poppedVdoContr.appendChild(playerWindow);
poppedVdoContr.style.display = "block";
} else {
mainPlayerWindow[0].insertBefore(playerWindow, mainPlayerWindow[0].firstChild);
poppedVdoContr.style.display = "none";
}
}
function manageVolume(e) {
var delta;
e.preventDefault(); // Keep page from scrolling while in video area
// Detect scroll direction
if (e.wheelDelta) delta = e.wheelDelta; else delta = -1 * e.deltaY;
// Vol UP || Vol DOWN
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;
elmnt.onmousedown = dragMouseDown;
function dragMouseDown(e) {
e = e || window.event;
pauseEvent(e);
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
pauseEvent(e);
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
}
function closeDragElement(e) {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
function pauseEvent(e) {
if(e.stopPropagation) e.stopPropagation();
if(e.preventDefault) e.preventDefault();
e.cancelBubble=true;
e.returnValue=false;
return false;
}
}
// load after important dom elements are present
$(document).arrive("#player-container", function() {
setupContentandInsert();
});

4
src/scripts/jquery-3.2.1.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,56 @@
html, body {
background: white;
width: 200px;
}
.ytThumbMenuStyle, .ytMenuStyle {
z-index:100;
position:fixed;
background:rgba(0,0,0,0.64);
margin-left:auto;;
margin-right:auto;
width:auto;
height:auto;
}
.ytThumbMenuStyle {
display:none;
bottom:65px;
}
.ytMenuStyle {
bottom:0px;
}
.imageStyle {
width:32px;
height:32px;
margin-right:0.5em;
}
.imageStyle:hover {
background:rgba(12,160,193,.64);
cursor: pointer;
}
#xIconHoverTop {
margin-bottom: 80px;
}
.thumbImageStyle {
width: 200px;
height: 100px;
margin-right: 2em;
}
#draggable {
z-index: 100;
position: fixed;
right: 0px;
bottom: 0px;
min-width: 400px;
min-height: 250px;
width: 650px;
height: 400px;
background: black;
}