Skip to content

Commit cff2ebe

Browse files
committed
Selectable subtitles, fix visitedColor
Closes (#31)
1 parent cc96e89 commit cff2ebe

7 files changed

Lines changed: 52 additions & 32 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nebulaenhance",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"private": true,
55
"description": "Enhancer for Nebula. Adds some quality of life features to the nebula player.",
66
"type": "module",

src/_locales/de/messages.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,21 @@
7575
"message": "Ob beim Scrollen über den Videospieler die Lautstärke geändert werden soll. Optional in logarithmischer Skala (anstatt linear).",
7676
"description": "Hilfstext für Volume Scroll der Optionen Seite."
7777
},
78-
"optionsFirstSubtitleTitle": {
79-
"message": "Ersten Untertitel aktivieren",
80-
"description": "Beschriftung für First Subtitle der Optionen Seite."
78+
"optionsSubtitleTitle": {
79+
"message": "Untertitel",
80+
"description": "Beschriftung für Subtitle der Optionen Seite."
81+
},
82+
"optionsSubtitleHint": {
83+
"message": "Ob Untertitel interagierbar gemacht werden sollen.<br/>Ob beim Klick auf den Untertitel-Knopf die erste Spur aktiviert werden soll, wenn sie die einzige ist.",
84+
"description": "Hilfstext für Subtitle der Optionen Seite."
8185
},
82-
"optionsFirstSubtitleHint": {
83-
"message": "Ob beim Klick auf den Untertitel-Knopf die erste Spur aktiviert werden soll, wenn sie die einzige ist.",
84-
"description": "Hilfstext für First Subtitle der Optionen Seite."
86+
"optionsSubtitleSelectable": {
87+
"message": "Interagierbar machen",
88+
"description": "Beschriftung für Subtitle Selectable der Optionen Seite."
89+
},
90+
"optionsSubtitleFirst": {
91+
"message": "Ersten aktivieren",
92+
"description": "Beschriftung für First Subtitle der Optionen Seite."
8593
},
8694
"optionsLoadYoutubeTitle": {
8795
"message": "YouTube Videolink laden",
@@ -200,7 +208,7 @@
200208
"description": "Beschriftung fürs Anzeigen von Changelogs der Optionen Seite."
201209
},
202210
"optionsShowChangelogHint": {
203-
"message": "Ob die Changelogs nach dem Aktualisieren der Erweiterung angezeigt werden sollen.",
211+
"message": "Ob die Changelogs nach dem Aktualisieren der Erweiterung angezeigt werden sollen (nur Englisch).",
204212
"description": "Hilfstext fürs Anzeigen von Changelogs der Optionen Seite."
205213
},
206214
"optionsShowChangelogButton": {

src/_locales/en/messages.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,21 @@
7575
"message": "Whether to make scrolling over the player change the playback volume. Optionally in logarithmic scale (as opposed to linear).",
7676
"description": "Hint for Volume Scroll of options page."
7777
},
78-
"optionsFirstSubtitleTitle": {
79-
"message": "Use first subtitle",
80-
"description": "Label for First Subtitle of options page."
78+
"optionsSubtitleTitle": {
79+
"message": "Subtitles",
80+
"description": "Label for Subtitle of options page."
81+
},
82+
"optionsSubtitleHint": {
83+
"message": "Whether to make subtitles interactable.<br/>Whether clicking on the subtitle button of the player should use the first available track if it is the only one.",
84+
"description": "Hint for Subtitle of options page."
8185
},
82-
"optionsFirstSubtitleHint": {
83-
"message": "Whether clicking on the subtitle button of the player should use the first available track if it is the only one.",
84-
"description": "Hint for First Subtitle of options page."
86+
"optionsSubtitleSelectable": {
87+
"message": "Make selectable",
88+
"description": "Label for Subtitle Selectable of options page."
89+
},
90+
"optionsSubtitleFirst": {
91+
"message": "Use first",
92+
"description": "Label for First Subtitle of options page."
8593
},
8694
"optionsLoadYoutubeTitle": {
8795
"message": "Load YouTube link",

src/options.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ <h3 class="enhancer-field-title i18n">__MSG_optionsVolumeScrollShow__</h3>
7575
</div>
7676

7777
<div class="enhancer-field">
78-
<h3 class="enhancer-field-title i18n">__MSG_optionsFirstSubtitleTitle__</h3>
78+
<h3 class="enhancer-field-title i18n">__MSG_optionsSubtitleTitle__</h3>
79+
80+
<label for="subtitlesSelectable" class="enhancer-checkbox">
81+
<input type="checkbox" name="subtitlesSelectable" id="subtitlesSelectable" data-default="" />
82+
<span class="i18n">__MSG_optionsSubtitleSelectable__</span>
83+
</label>
7984

8085
<label for="useFirstSubtitle" class="enhancer-checkbox">
8186
<input type="checkbox" name="useFirstSubtitle" id="useFirstSubtitle" data-default="" />
82-
<span class="i18n">__MSG_optionsEnable__</span>
87+
<span class="i18n">__MSG_optionsSubtitleFirst__</span>
8388
</label>
8489

85-
<p class="hint i18n">__MSG_optionsFirstSubtitleHint__</p>
90+
<p class="hint i18n">__MSG_optionsSubtitleHint__</p>
8691
</div>
8792
</section>
8893

src/scripts/content/nebula/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ export const nebula = async () => {
2323
hiddenCreators: h,
2424
hideVideosEnabled,
2525
hideVideosPerc,
26+
subtitlesSelectable,
27+
visitedColor,
2628
} = await getFromStorage({
2729
youtube: false,
2830
theme: '',
2931
customScriptPage: '',
3032
hiddenCreators: [] as string[],
3133
hideVideosEnabled: false,
3234
hideVideosPerc: 80,
35+
subtitlesSelectable: false,
36+
visitedColor: '',
3337
});
3438
hiddenCreators = h;
35-
console.debug('Youtube:', youtube, 'Theme:', theme,
39+
console.debug('Youtube:', youtube, 'Theme:', theme, 'subtitles selectable?', subtitlesSelectable, 'visitedColor:', visitedColor,
3640
'\nHiding', hiddenCreators.length, 'creators', '\tvideos?', hideVideosEnabled, 'with perc watched:', hideVideosPerc);
3741

3842
if (!theme) try {
@@ -70,6 +74,10 @@ export const nebula = async () => {
7074
// set hidden creator overlay content from translation
7175
const s = document.createElement('style');
7276
s.textContent = `.enhancer-hiddenVideo::after { content: ${JSON.stringify(msg('pageCreatorHidden'))}; }`;
77+
if (subtitlesSelectable) s.textContent += '\n.vjs-text-track-cue { pointer-events:all; }';
78+
const c = visitedColor.split(';')[0];
79+
if (c) s.textContent += `\n:root { --visited-color: ${c}; }\na[href^='/videos/']:visited > div > * /* video link */ { color: var(--visited-color); }`;
80+
document.head.appendChild(s);
7381
document.head.appendChild(s);
7482

7583
document.body.classList.add('enhancer-initialized');

src/scripts/options/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class Settings {
1111
volumeLog: HTMLInputElement = undefined;
1212
volumeShow: HTMLInputElement = undefined;
1313
volumeChange: HTMLInputElement = undefined;
14+
subtitlesSelectable: HTMLInputElement = undefined;
1415
useFirstSubtitle: HTMLInputElement = undefined;
1516
youtube: HTMLInputElement = undefined;
1617
ytOpenTab: HTMLInputElement = undefined;

src/scripts/page/player.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { init as initDispatch, loadPrefix } from './dispatcher';
88

99
type Comp<T> = T extends (...args: any[]) => Promise<infer R> ? R : T extends (...args: any[]) => infer R ? R : never;
1010

11-
function getFromStorage<T extends { [key: string]: any }>(key: T): Promise<T>;
11+
function getFromStorage<T extends { [key: string]: any; }>(key: T): Promise<T>;
1212
function getFromStorage<T>(key: string | string[]): Promise<T>;
13-
function getFromStorage<T>(key: string | string[] | { [key: string]: any }) {
13+
function getFromStorage<T>(key: string | string[] | { [key: string]: any; }) {
1414
return sendMessage<T>(Message.GET_STORAGE, { get: key });
1515
}
1616

@@ -23,17 +23,16 @@ const defaults = {
2323
volumeChange: 0.1,
2424
volumeLog: false,
2525
useFirstSubtitle: false,
26-
visitedColor: '',
2726
};
2827

2928
export const init = async () => {
3029
const {
3130
playbackChange, autoplay, autoplayQueue, volumeEnabled,
32-
volumeChange, volumeLog, volumeShow, useFirstSubtitle, visitedColor,
31+
volumeChange, volumeLog, volumeShow, useFirstSubtitle,
3332
} = await getFromStorage(defaults);
3433
console.debug('playbackChange:', playbackChange, 'autoplay?', autoplay, 'autoplay in queue?', autoplayQueue,
3534
'\nvolume scroll?', volumeEnabled, 'change:', volumeChange, 'log?', volumeLog, 'show?', volumeShow,
36-
'\nuse first subtitle?', useFirstSubtitle, 'visitedColor:', visitedColor);
35+
'\nuse first subtitle?', useFirstSubtitle);
3736

3837
await waitForVJS();
3938
await registerComponents(playbackChange, volumeShow);
@@ -46,15 +45,6 @@ export const init = async () => {
4645
document.addEventListener('click', clickHandler, { capture: true });
4746
document.addEventListener(`${loadPrefix}-video`, initPlayer);
4847
initDispatch();
49-
50-
const c = visitedColor.split(';')[0];
51-
if (!c) return;
52-
const s = document.createElement('style');
53-
s.textContent = `
54-
:root { --visited-color: ${c}; }
55-
a[href^='/videos/']:visited /* video link */ { color: var(--visited-color); }
56-
`;
57-
document.head.appendChild(s);
5848
};
5949

6050
export const initPlayer = async () => {

0 commit comments

Comments
 (0)