Skip to content

Commit

Permalink
New Custom Mini-Player
Browse files Browse the repository at this point in the history
  • Loading branch information
adokseo committed Aug 4, 2020
1 parent 11a8eb3 commit 03fc86d
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 3 deletions.
26 changes: 25 additions & 1 deletion content-scripts.css
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,11 @@ html[data-cursor='e-resize'] *
html[it-mini-player-cursor='n-resize']::after,
html[it-mini-player-cursor='e-resize']::after,
html[it-mini-player-cursor='s-resize']::after,
html[it-mini-player-cursor='w-resize']::after
html[it-mini-player-cursor='w-resize']::after,
html[it-mini-player-cursor='ne-resize']::after,
html[it-mini-player-cursor='se-resize']::after,
html[it-mini-player-cursor='sw-resize']::after,
html[it-mini-player-cursor='nw-resize']::after
{
content: '';
position: fixed;
Expand Down Expand Up @@ -1888,6 +1892,26 @@ html[it-mini-player-cursor='w-resize']::after
cursor: w-resize;
}

html[it-mini-player-cursor='ne-resize']::after
{
cursor: ne-resize;
}

html[it-mini-player-cursor='se-resize']::after
{
cursor: se-resize;
}

html[it-mini-player-cursor='sw-resize']::after
{
cursor: sw-resize;
}

html[it-mini-player-cursor='nw-resize']::after
{
cursor: nw-resize;
}


/*-----------------------------------------------------------------------------
2.3 Multipage
Expand Down
60 changes: 60 additions & 0 deletions content-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,13 @@ ImprovedTube.mini_player__mousedown = function (event) {
};

ImprovedTube.mini_player__mouseup = function () {
var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

strg.x = ImprovedTube.mini_player__x;
strg.y = ImprovedTube.mini_player__y;

localStorage.setItem('improedtube-mini-player', JSON.stringify(strg));

window.removeEventListener('mouseup', ImprovedTube.mini_player__mouseup);
window.removeEventListener('mousemove', ImprovedTube.mini_player__mousemove);

Expand Down Expand Up @@ -1730,6 +1737,34 @@ ImprovedTube.mini_player__cursorUpdate = function (event) {
c = ImprovedTube.mini_player__cursor;

if (
x >= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - ImprovedTube.mini_player__resize_offset &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width &&
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
c = 'ne-resize';
} else if (
x >= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - ImprovedTube.mini_player__resize_offset &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width &&
y >= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - ImprovedTube.mini_player__resize_offset &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height
) {
c = 'se-resize';
} else if (
x >= ImprovedTube.mini_player__x &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__resize_offset &&
y >= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - ImprovedTube.mini_player__resize_offset &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height
) {
c = 'sw-resize';
} else if (
x >= ImprovedTube.mini_player__x &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__resize_offset &&
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
c = 'nw-resize';
} else if (
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
Expand Down Expand Up @@ -1781,6 +1816,17 @@ ImprovedTube.mini_player__resize_mouseMove = function(event) {
} else if (ImprovedTube.mini_player__cursor === 'w-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, ImprovedTube.mini_player__y);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, ImprovedTube.mini_player__height);
} else if (ImprovedTube.mini_player__cursor === 'ne-resize') {
ImprovedTube.mini_player__setPosition(ImprovedTube.mini_player__x, event.clientY);
ImprovedTube.mini_player__setSize(event.clientX - ImprovedTube.mini_player__x, ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - event.clientY);
} else if (ImprovedTube.mini_player__cursor === 'se-resize') {
ImprovedTube.mini_player__setSize(event.clientX - ImprovedTube.mini_player__x, event.clientY - ImprovedTube.mini_player__y);
} else if (ImprovedTube.mini_player__cursor === 'sw-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, ImprovedTube.mini_player__y);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, event.clientY - ImprovedTube.mini_player__y);
} else if (ImprovedTube.mini_player__cursor === 'nw-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, event.clientY);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - event.clientY);
}
};

Expand All @@ -1792,6 +1838,13 @@ ImprovedTube.mini_player__resize_mouseUp = function(event) {
ImprovedTube.mini_player__width = bcr.width;
ImprovedTube.mini_player__height = bcr.height;

var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

strg.width = ImprovedTube.mini_player__width;
strg.height = ImprovedTube.mini_player__height;

localStorage.setItem('improedtube-mini-player', JSON.stringify(strg));

window.addEventListener('mousemove', ImprovedTube.mini_player__cursorUpdate);
window.removeEventListener('mouseup', ImprovedTube.mini_player__resize_mouseUp);
window.removeEventListener('mousemove', ImprovedTube.mini_player__resize_mouseMove);
Expand All @@ -1801,6 +1854,13 @@ ImprovedTube.mini_player = function() {
ImprovedTube.mini_player__element = document.querySelector('.html5-video-player');

if (ImprovedTube.storage.mini_player === true) {
var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

ImprovedTube.mini_player__x = ImprovedTube.isset(strg.x) ? strg.x : 16;
ImprovedTube.mini_player__y = ImprovedTube.isset(strg.y) ? strg.y : 16;
ImprovedTube.mini_player__width = strg.width || 200;
ImprovedTube.mini_player__height = strg.height || 150;

window.addEventListener('scroll', ImprovedTube.mini_player__scroll);
} else {
ImprovedTube.mini_player__mode = false;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"short_name" : "ImprovedTube",
"name": "Improve YouTube! (Open-Source for YouTube)",
"version": "3.59",
"version": "3.61",
"icons": {
"16": "assets/icons/16.png",
"32": "assets/icons/32.png",
Expand Down
26 changes: 25 additions & 1 deletion src/youtube/css/player.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ html[data-cursor='e-resize'] *
html[it-mini-player-cursor='n-resize']::after,
html[it-mini-player-cursor='e-resize']::after,
html[it-mini-player-cursor='s-resize']::after,
html[it-mini-player-cursor='w-resize']::after
html[it-mini-player-cursor='w-resize']::after,
html[it-mini-player-cursor='ne-resize']::after,
html[it-mini-player-cursor='se-resize']::after,
html[it-mini-player-cursor='sw-resize']::after,
html[it-mini-player-cursor='nw-resize']::after
{
content: '';
position: fixed;
Expand Down Expand Up @@ -139,6 +143,26 @@ html[it-mini-player-cursor='w-resize']::after
cursor: w-resize;
}

html[it-mini-player-cursor='ne-resize']::after
{
cursor: ne-resize;
}

html[it-mini-player-cursor='se-resize']::after
{
cursor: se-resize;
}

html[it-mini-player-cursor='sw-resize']::after
{
cursor: sw-resize;
}

html[it-mini-player-cursor='nw-resize']::after
{
cursor: nw-resize;
}


/*-----------------------------------------------------------------------------
2.3 Multipage
Expand Down
60 changes: 60 additions & 0 deletions src/youtube/js/features/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ ImprovedTube.mini_player__mousedown = function (event) {
};

ImprovedTube.mini_player__mouseup = function () {
var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

strg.x = ImprovedTube.mini_player__x;
strg.y = ImprovedTube.mini_player__y;

localStorage.setItem('improedtube-mini-player', JSON.stringify(strg));

window.removeEventListener('mouseup', ImprovedTube.mini_player__mouseup);
window.removeEventListener('mousemove', ImprovedTube.mini_player__mousemove);

Expand Down Expand Up @@ -368,6 +375,34 @@ ImprovedTube.mini_player__cursorUpdate = function (event) {
c = ImprovedTube.mini_player__cursor;

if (
x >= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - ImprovedTube.mini_player__resize_offset &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width &&
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
c = 'ne-resize';
} else if (
x >= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - ImprovedTube.mini_player__resize_offset &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__width &&
y >= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - ImprovedTube.mini_player__resize_offset &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height
) {
c = 'se-resize';
} else if (
x >= ImprovedTube.mini_player__x &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__resize_offset &&
y >= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - ImprovedTube.mini_player__resize_offset &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__height
) {
c = 'sw-resize';
} else if (
x >= ImprovedTube.mini_player__x &&
x <= ImprovedTube.mini_player__x + ImprovedTube.mini_player__resize_offset &&
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
c = 'nw-resize';
} else if (
y >= ImprovedTube.mini_player__y &&
y <= ImprovedTube.mini_player__y + ImprovedTube.mini_player__resize_offset
) {
Expand Down Expand Up @@ -419,6 +454,17 @@ ImprovedTube.mini_player__resize_mouseMove = function(event) {
} else if (ImprovedTube.mini_player__cursor === 'w-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, ImprovedTube.mini_player__y);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, ImprovedTube.mini_player__height);
} else if (ImprovedTube.mini_player__cursor === 'ne-resize') {
ImprovedTube.mini_player__setPosition(ImprovedTube.mini_player__x, event.clientY);
ImprovedTube.mini_player__setSize(event.clientX - ImprovedTube.mini_player__x, ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - event.clientY);
} else if (ImprovedTube.mini_player__cursor === 'se-resize') {
ImprovedTube.mini_player__setSize(event.clientX - ImprovedTube.mini_player__x, event.clientY - ImprovedTube.mini_player__y);
} else if (ImprovedTube.mini_player__cursor === 'sw-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, ImprovedTube.mini_player__y);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, event.clientY - ImprovedTube.mini_player__y);
} else if (ImprovedTube.mini_player__cursor === 'nw-resize') {
ImprovedTube.mini_player__setPosition(event.clientX, event.clientY);
ImprovedTube.mini_player__setSize(ImprovedTube.mini_player__x + ImprovedTube.mini_player__width - event.clientX, ImprovedTube.mini_player__y + ImprovedTube.mini_player__height - event.clientY);
}
};

Expand All @@ -430,6 +476,13 @@ ImprovedTube.mini_player__resize_mouseUp = function(event) {
ImprovedTube.mini_player__width = bcr.width;
ImprovedTube.mini_player__height = bcr.height;

var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

strg.width = ImprovedTube.mini_player__width;
strg.height = ImprovedTube.mini_player__height;

localStorage.setItem('improedtube-mini-player', JSON.stringify(strg));

window.addEventListener('mousemove', ImprovedTube.mini_player__cursorUpdate);
window.removeEventListener('mouseup', ImprovedTube.mini_player__resize_mouseUp);
window.removeEventListener('mousemove', ImprovedTube.mini_player__resize_mouseMove);
Expand All @@ -439,6 +492,13 @@ ImprovedTube.mini_player = function() {
ImprovedTube.mini_player__element = document.querySelector('.html5-video-player');

if (ImprovedTube.storage.mini_player === true) {
var strg = JSON.parse(localStorage.getItem('improedtube-mini-player')) || {};

ImprovedTube.mini_player__x = ImprovedTube.isset(strg.x) ? strg.x : 16;
ImprovedTube.mini_player__y = ImprovedTube.isset(strg.y) ? strg.y : 16;
ImprovedTube.mini_player__width = strg.width || 200;
ImprovedTube.mini_player__height = strg.height || 150;

window.addEventListener('scroll', ImprovedTube.mini_player__scroll);
} else {
ImprovedTube.mini_player__mode = false;
Expand Down

0 comments on commit 03fc86d

Please sign in to comment.