Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Disliked Songs #1505

Merged
merged 7 commits into from
Dec 9, 2023
Merged

Skip Disliked Songs #1505

merged 7 commits into from
Dec 9, 2023

Conversation

MiepHD
Copy link
Contributor

@MiepHD MiepHD commented Dec 8, 2023

Fixes #638

@ArjixWasTaken
Copy link
Contributor

I highly suggest that you run that code through a code formatter, those one-liners are too long.
Also, there is no guarantee that the elements you are querying actually exist, please put some logic to handle that.

I can help you with that if you are not sure how to do it.
Last but not least, please add a stop() callback, this plugin should not require a restart in order to be fully disabled.

@JellyBrick JellyBrick added the enhancement New feature or request label Dec 8, 2023
@MiepHD MiepHD marked this pull request as draft December 8, 2023 19:03
@MiepHD MiepHD marked this pull request as ready for review December 8, 2023 19:29
@MiepHD
Copy link
Contributor Author

MiepHD commented Dec 8, 2023

Also, there is no guarantee that the elements you are querying actually exist, please put some logic to handle that.

I'm not sure how I could handle that

@ArjixWasTaken
Copy link
Contributor

ArjixWasTaken commented Dec 8, 2023

I'm not sure how I could handle that

In some of my userscript's I've used a helper method to ensure my code runs at the correct time.

const waitForElem = (selector) => {
    return new Promise(resolve => {
        const interval = setInterval(() => {
            const elem = document.querySelector(selector);
            if (!elem) return;

            clearInterval(interval);
            resolve(elem);
        });
    });
}

and then

const likeBtn = await waitForElem('#like-button-renderer');

// ...
.observe(likeBtn, ...)

@MiepHD
Copy link
Contributor Author

MiepHD commented Dec 8, 2023

The button exists even if no song is selected and I think I can assume that the page is fully loaded at start(), right?

@ArjixWasTaken
Copy link
Contributor

It ain't bad to be always careful, we don't want users experiencing unexpected bugs.

src/plugins/skip-disliked-songs/index.ts Outdated Show resolved Hide resolved
src/plugins/skip-disliked-songs/index.ts Outdated Show resolved Hide resolved
MiepHD and others added 3 commits December 8, 2023 20:55
Co-authored-by: JellyBrick <shlee1503@naver.com>
Co-authored-by: JellyBrick <shlee1503@naver.com>
Co-authored-by: JellyBrick <shlee1503@naver.com>
@JellyBrick
Copy link
Collaborator

Other than that, LGTM

@MiepHD MiepHD requested a review from JellyBrick December 8, 2023 20:32
@ArjixWasTaken
Copy link
Contributor

LGTM as well

@JellyBrick JellyBrick merged commit 45e5bc7 into th-ch:master Dec 9, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Skip disliked songs
3 participants