Skip to content

Commit bb24e83

Browse files
committed
Version bump, youtube comments use url
YT: Use nebula channel url as alternative to match channel should fix no matches for different names (e.g. Wendover / Wendover Productions)
1 parent 799e7e2 commit bb24e83

4 files changed

Lines changed: 10 additions & 7 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.0.2",
3+
"version": "1.0.3",
44
"private": true,
55
"description": "Enhancer for Nebula. Adds some quality of life features to the nebula player.",
66
"type": "module",

src/scripts/background_script.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ getBrowserInstance().browserAction.onClicked.addListener(() => openOptions());
1111
getBrowserInstance().runtime.onMessage.addListener(async (message: string | { [key: string]: any }) => {
1212
try {
1313
const msg = parseTypeObject(message);
14+
console.dev.log('Handling message', msg);
1415
switch (msg.type) {
1516
case BrowserMessage.LOAD_CREATORS:
1617
return console.debug(await loadCreators());
@@ -44,12 +45,13 @@ const loadCreators = (() => {
4445
})();
4546

4647
const getYoutubeId = async (message: { [key: string]: any }) => {
47-
const { creator, title } = message;
48+
const { creator, title, nebula } = message;
4849
const normalizedCreator = normalizeString(creator);
50+
console.debug('creator:', creator, '\nnebula:', nebula, '\ntitle:', title);
4951

5052
try {
5153
const creators = await loadCreators();
52-
const uploads = creators.find(e => e.name === creator || normalizeString(e.name) === normalizedCreator)?.uploads;
54+
const uploads = creators.find(e => e.name === creator || normalizeString(e.name) === normalizedCreator || e.nebula === nebula)?.uploads;
5355
return creatorHasYTVideo(uploads, title, videoFetchYt);
5456
} catch (err) {
5557
console.error(err);
@@ -62,7 +64,7 @@ const getNebulaVideo = async (message: { [key: string]: any }): Promise<nebulavi
6264

6365
const creators = await loadCreators();
6466
const creator = creators.find(c => c.channel === channelID);
65-
console.debug('creator:', creator);
67+
console.debug('creator:', creator, '\nchannelID:', channelID, '\nvideoTitle:', videoTitle);
6668
if (!creator) return;
6769

6870
// try search the channel's newest videos locally

src/scripts/content/nebula/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,15 @@ const loadComments = async () => {
148148
if (h2.length < 2) return;
149149
const title = h2[0].textContent;
150150
const creator = h2[1].textContent;
151+
const nebula = (h2[1].parentElement as HTMLAnchorElement).href;
151152
if (!title || !creator) return;
152153
const e = h2[0].nextElementSibling;
153154
if (!e || e.querySelector('.enhancer-yt, .enhancer-yt-err'))
154155
return; // already requested
155-
console.debug(`Requesting '${title}' by ${creator}`);
156+
console.debug(`Requesting '${title}' by ${creator} (${nebula})`);
156157

157158
try {
158-
const vid: ytvideo = await getBrowserInstance().runtime.sendMessage({ type: BrowserMessage.GET_YTID, creator, title });
159+
const vid: ytvideo = await getBrowserInstance().runtime.sendMessage({ type: BrowserMessage.GET_YTID, creator, title, nebula });
159160
console.debug('Found video:', vid);
160161
const v = document.createElement('span');
161162
v.classList.add('enhancer-yt');

src/scripts/helpers/api/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const refreshToken = async () => {
1010
try {
1111
({ apiToken } = JSON.parse(cookie));
1212
} catch (e) {
13-
console.debug(e);
13+
console.dev.warn(e);
1414
}
1515
const apiAuth = apiToken ? { Authorization: `Token ${apiToken}` } : {};
1616
console.dev.debug('Refreshing nebula token using auth', apiAuth);

0 commit comments

Comments
 (0)