forked from austencm/youtube-auto-like
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Likes YouTube videos. | ||
* For the newer paper design layout | ||
*/ | ||
class GridLiker extends MetaLiker { | ||
|
||
VIDEO_SELECTOR = ".video-stream"; | ||
ACTION_ELEMENTS_SELECTOR = "#secondary-inner ytd-watch-metadata ytd-menu-renderer segmented-like-dislike-button-view-model"; | ||
LIKE_SELECTOR = "like-button-view-model button"; | ||
DISLIKE_SELECTOR = "dislike-button-view-model button"; | ||
LIVE_SELECTOR = ".ytp-live-badge[disabled='']"; | ||
|
||
isVideoRated(like, dislike) { | ||
return like.attributes["aria-pressed"].nodeValue === "true" || | ||
dislike.attributes["aria-pressed"].nodeValue === "true"; | ||
} | ||
|
||
/* | ||
* Another tough one | ||
* @return {Boolean} True if the user is subscribed to | ||
* the current video's channel | ||
*/ | ||
isUserSubscribed() { | ||
let subscribeButtons = document.querySelectorAll("ytd-subscribe-button-renderer :not(*[hidden]) button.yt-spec-button-shape-next--tonal") | ||
// the ':not(*[hidden]) ytd-subscribe-button-renderer :not(*[hidden]) button.yt-spec-button-shape-next--tonal' | ||
// does not work, thus use isHidden | ||
let buttonExist = subscribeButtons.length > 0 | ||
log("sub button exist: ", buttonExist) | ||
if (!buttonExist) return false | ||
|
||
let subscribeButton = Array.from(subscribeButtons).find(isNotHidden) | ||
log("sub button not hidden: ", subscribeButton) | ||
return subscribeButton !== undefined; | ||
} | ||
} |
Oops, something went wrong.