Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,14 @@
},
"smartSpeedAddSelectedLanguage": {
"message": "➕ Add Selected Language"
},
"zenMode": {
"message": "Zen mode"
},
"dimEverythingElse": {
"message": "Dim everything except the player"
},
"hideEverythingElse": {
"message": "Hide everything except the player"
}
}

1 change: 1 addition & 0 deletions js&css/extension/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const pageWorldFiles = [
'/js&css/web-accessible/www.youtube.com/last-watched-overlay.js', // Neue Zeile hinzufügen
'/js&css/web-accessible/www.youtube.com/return-youtube-dislike.js',
'/js&css/web-accessible/www.youtube.com/return-youtube-dislike.css',
'/js&css/web-accessible/www.youtube.com/features/zen.js',
'/js&css/web-accessible/init.js'
];

Expand Down
51 changes: 51 additions & 0 deletions js&css/extension/www.youtube.com/features/zen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*--------------------------------------------------------------
>>> ZEN MODE
----------------------------------------------------------------
Activated by the it-zen-mode attribute that the extension writes to
<html> for the zen_mode setting. "dim" fades the page; "hide" keeps
only the player.
--------------------------------------------------------------*/
html[it-zen-active][it-zen-mode="hide"] ytd-masthead,
html[it-zen-active][it-zen-mode="hide"] #masthead-container,
html[it-zen-active][it-zen-mode="hide"] #guide,
html[it-zen-active][it-zen-mode="hide"] ytd-mini-guide-renderer,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #secondary,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #comments,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #below,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #chat,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #chat-container,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-next-secondary-results-renderer {
display: none !important;
}

html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #columns,
html[it-zen-active][it-zen-mode="hide"] ytd-watch-flexy #primary,
html[it-zen-active][it-zen-mode="hide"] #player-container-outer,
html[it-zen-active][it-zen-mode="hide"] #player-full-bleed-container {
max-width: none !important;
margin: 0 !important;
padding: 0 !important;
}

html[it-zen-active][it-zen-mode="hide"] body {
background: #000 !important;
}

html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #secondary,
html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #below,
html[it-zen-active][it-zen-mode="dim"] ytd-masthead,
html[it-zen-active][it-zen-mode="dim"] #guide {
opacity: .2 !important;
transition: opacity .2s ease;
}

html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #secondary:hover,
html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #secondary:focus-within,
html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #below:hover,
html[it-zen-active][it-zen-mode="dim"] ytd-watch-flexy #below:focus-within,
html[it-zen-active][it-zen-mode="dim"] ytd-masthead:hover,
html[it-zen-active][it-zen-mode="dim"] ytd-masthead:focus-within,
html[it-zen-active][it-zen-mode="dim"] #guide:hover,
html[it-zen-active][it-zen-mode="dim"] #guide:focus-within {
opacity: 1 !important;
}
71 changes: 71 additions & 0 deletions js&css/web-accessible/www.youtube.com/features/zen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*--------------------------------------------------------------
>>> ZEN MODE EXIT
----------------------------------------------------------------
The CSS does the hiding. This module adds one way back out: a
floating Exit button and Escape, both of which write zen_mode=off
through the same storage bridge the menu uses.
--------------------------------------------------------------*/
(function () {
'use strict';

function mode() {
return ImprovedTube.storage.zen_mode;
}

function active() {
var value = mode();
return value === 'hide' || value === 'dim';
}

function exit() {
if (!active()) return;
ImprovedTube.storage.zen_mode = 'off';
ImprovedTube.messages.send({ action: 'set', key: 'zen_mode', value: 'off' });
apply();
}

function apply() {
var button = document.querySelector('#it-zen-exit');
var onVideo = location.pathname === '/watch' || location.pathname.startsWith('/live/');
document.documentElement.toggleAttribute('it-zen-active', active() && onVideo);

if (!active() || !onVideo) {
if (button) {
button.remove();
}
return;
}

if (button || !document.body) {
return;
}

var dark = document.documentElement.hasAttribute('dark'),
el = document.createElement('button');

el.id = 'it-zen-exit';
el.type = 'button';
el.textContent = 'Exit Zen';
el.title = 'Exit Zen mode (Esc)';
el.style.cssText = 'position:fixed;right:16px;top:16px;z-index:2147483000;padding:8px 12px;border:0;border-radius:999px;cursor:pointer;font:600 12px/1 Roboto,Arial,sans-serif;background:' +
(dark ? 'rgba(255,255,255,.14)' : 'rgba(0,0,0,.08)') + ';color:' + (dark ? '#f1f1f1' : '#0f0f0f');
el.style.backdropFilter = 'blur(8px)';
el.addEventListener('click', exit);

document.body.appendChild(el);
}

document.addEventListener('init_completed', apply);
document.addEventListener('DOMContentLoaded', apply);
document.addEventListener('yt-navigate-finish', apply);
ImprovedTube.zenMode = apply;
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape' && active() && document.documentElement.hasAttribute('it-zen-active') && !document.fullscreenElement
&& !event.defaultPrevented && !event.target.isContentEditable && !/^(INPUT|TEXTAREA|SELECT)$/.test(event.target.tagName)) {
exit();
}
});

ImprovedTube.zenModeActive = active;
ImprovedTube.zenModeExit = exit;
})();
4 changes: 3 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"js&css/extension/www.youtube.com/appearance/player/player.css",
"js&css/extension/www.youtube.com/appearance/details/details.css",
"js&css/extension/www.youtube.com/appearance/sidebar/sidebar.css",
"js&css/extension/www.youtube.com/appearance/comments/comments.css"
"js&css/extension/www.youtube.com/appearance/comments/comments.css",
"js&css/extension/www.youtube.com/features/zen.css"
],
"exclude_matches": [
"https://www.youtube.com/audiolibrary/*",
Expand Down Expand Up @@ -81,6 +82,7 @@
"js&css/web-accessible/www.youtube.com/return-youtube-dislike.js",
"js&css/web-accessible/www.youtube.com/return-youtube-dislike.css",
"js&css/web-accessible/init.js",
"js&css/web-accessible/www.youtube.com/features/zen.js",
"menu/icons/48.png"
],
"matches": ["https://www.youtube.com/*"]
Expand Down
1 change: 1 addition & 0 deletions menu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
<link rel="stylesheet" href="styles/mixer.css">
<link rel="stylesheet" href="styles/settings.css">
<link rel="stylesheet" href="styles/themes.css">
<script src="skeleton-parts/zen.js"></script>
</head><body><div id="loading" style="animation: 3s linear 0s 1 normal none running fadeIn; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 3px solid rgb(182, 233, 255); border-radius: 80px; padding: 37px; color: rgb(120, 147, 161);">...asking your browser what settings you made here before...</div>
</body></html>
31 changes: 31 additions & 0 deletions menu/skeleton-parts/zen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*--------------------------------------------------------------
>>> ZEN MODE
--------------------------------------------------------------*/

extension.skeleton.main.layers.section.appearance.on.click.zen = {
component: 'button',
variant: 'zen',
text: 'zenMode',
tags: 'focus,dim,distraction,study,presentation,clean,minimal,hide',
on: {
click: {
component: 'section',
variant: 'card',

zen_mode: {
component: 'select',
text: 'zenMode',
options: [{
text: 'disabled',
value: 'off'
}, {
text: 'dimEverythingElse',
value: 'dim'
}, {
text: 'hideEverythingElse',
value: 'hide'
}]
}
}
}
};
Loading
Loading