Giter VIP home page Giter VIP logo

cvzi / youtube-genius-lyrics-userscript Goto Github PK

View Code? Open in Web Editor NEW
32.0 4.0 5.0 4.11 MB

Userscript, Show lyrics/songtexts from genius.com on Youtube next to music videos

Home Page: https://greasyfork.org/en/scripts/386259-youtube-genius-lyrics

License: GNU General Public License v3.0

JavaScript 100.00%
genius youtube genius-lyrics lyrics songtext userscript greasemonkey-script music-video

youtube-genius-lyrics-userscript's Introduction

Youtube-Genius-Lyrics-userscript

Description:

A userscript or greasemonkey script that shows lyrics from genius.com on YouTube music videos

This is a userscript for your browser. It's primarily designed for Firefox and Chrome with Tampermonkey Chrome logo Firefox logo

General information about userscripts and how to use them can be found at openuserjs.org/about/Userscript-Beginners-HOWTO.

Click here to install
Tested with Firefox/Tampermonkey and Chrome/Tampermonkey.

Family of GeniusLyrics Userscripts:

Contributors:

Contributors

Screenshots:

  • Year 2022
  • Default theme (Dynamic Color with YouTube Dark & Light Themes)
    • Note: YouTube is now moving forwards into the dark mode (Darker Dark Mode with Cinematic Annotations)
    • Using Light Theme is highly non-recommended Screenshot as of 2022 Screenshot as of 2022 (Light)
  • Integrated with Tabview Youtube
    • Tabview Youtube(GitHub) is a userscript developed by CY Fung to manage the page layout as tabs to maximize the watching experience. Screenshot as of 2022 with TabView Youtube
  • Year 2019 - 2021
  • Default theme Screenshot of youtube music video with lyrics
  • Dark (Spotify) theme Screenshot of youtube music video with lyrics (dark)

JavaScript Style Guide standardjs

youtube-genius-lyrics-userscript's People

Contributors

cvzi avatar cyfung1031 avatar eithoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

youtube-genius-lyrics-userscript's Issues

SyntaxError: Unexpected token

This userscript doesn't work for me. I sometimes get this error when I open a video and the lyrics never show up like in the screenshots. Clicking on the "Show lyrics" button in Tampermonkey does nothing. I tried disabling all Chrome extensions in case one of them interfered somehow but that doesn't seem to be the case.

image

Error message "You are unable to access genius.com"

Test the script on:
Jacques Brel - La valse ร  mille temps
Your script open a popu with this error message in html (i reduce it):

cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies
id="cf-error-details" class="cf-error-details-wrapper"
class="cf-wrapper cf-header cf-error-overview"
data-translate="block_headline" Sorry, you have been blocked
class="cf-subheadline" data-translate="unable_to_access" You are unable to access genius.com

data-translate="blocked_why_headline" Why have I been blocked?
data-translate="blocked_why_detail" This website is using a security service to protect itself from online attacks.
The action you just performed triggered the security solution.
There are several actions that could trigger this block including submitting a certain word or phrase,
a SQL command or malformed data.

data-translate="blocked_resolve_headline" What can I do to resolve this?
data-translate="blocked_resolve_detail" You can email the site owner to let them know you were blocked.
Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

The problem is on Waterfox Classic 2020.12
Your scritpt is installed with Tampermonkey [seems not working with (old) Greasemonkey 3.17]

But it work fine on Chrome and Firefox Quantum.

Suggestion: using yt-navigate-finish instead of setInterval

The script is currently using window.setInterval(main, 2000)
inside main(), it calls querySelector and textContent which are expensive.

Refer to the code, it just wants to check when the song is changed.
I recommend using yt-navigate-finish / yt-page-data-fetched / yt-page-data-updated to avoid the setInterval checking.
yt-navigate-finish should be the most easy one. This event triggers after the song changed and UI ready.

main(); // first call
document.addEventListener('yt-navigate-finish', main, false); // trigger when song is changed

Genius Lyrics's iframe creates history records

I understand that this script is using iframe to youtube domain robot txt to get the lyrcis.
I believe the linking inside iframe can be done by "location.replace(...)" instead of "location = XXX" or "location.href = XXX"

By using location.replace, the history record would not be affected (to the top frame).

Please consider such feature.
Since youtube can navigate among songs, the history modification would make trouble to this YouTube feature.

TO DO: Implementation of Speed 1 and Speed 2

Autoscroll currently using the speed automatically determined by the lyrics length
However if the song is not full version and the lyrics is, it will be too fast.
The speed shall be as similar as the normal song.
The speed conversion shall be introduced when the user click / switch the speed
the current position (progress) will be recorded as w0 (m0) and position will be changed into
pos_w = rate * pos_m + y0

rate(0) = 1
y0(0) = 0

After having the w0 (or m0),

w0(n) = rate(n) * m0(n) + y0(n)
rate(1) = new rate
rate(0) * m0 + y0(0) = rate(1) * m0 + y0(1)
y0(1) = y0(0) + ( rate(0) - rate(1) ) * m0

Speed 1: automatic
Speed 2: the specified rate according to correct songs, such as
https://www.youtube.com/watch?v=sXrkgyxATwg

The speed control will be entirely by the script inside iframe, including cubicBezier
This shall be moved into the library.
The external script will only provide the pos_m and let the library to do pos_w conversion.

Hi. autoShow is buggy.

Hi. autoShow is buggy.

HnmvvFn.md.png
HnmvOGt.md.png

video.getClientRects()[0].right shall change to video.getBoundingClientRect().right to avoid the bug.

Styling and Userscript Interfacing

Would you mind to provide some interfacing so that the genius object and the useful functions can be exported to the outside and called by other userscripts?

Right now I am doing some interfacing of your script with my script.
https://greasyfork.org/en/scripts/428651-tabview-youtube


Besides, there are three things I would like to do.

If you would like to include into your script, I am fine to share it.
If not, I would just add to my script to make these features.

Point 1) modify the css styling of the floating elements to adopt the darker dark theme

I know this youtube genius lyrics userscript is quite old and now YouTube has decided to make dark mode as default.
For me I think the old css styling used is a bit ugly.

Point 2) modify the css styling within the iframe

I just use the default theme (genius theme), looks like the texts are somehow broken especially the header and footer.
I have already figured out the required css.
For other two themes, seems not maintained and already broken?
Or add my styling as a separate theme?
For this purpose, I hope there is some exported functions that I can call to set the theme or add custom theme by css in order to incorporate my userscript design.

Point 3) a more accurate way to get the song title and author

I see there is some text processing for the video title to get the actual song name and author.
Base on the latest design, I have figured out another way to do it. But I don't know how to feed the title to your script correctly.

Actually it is quite easy.
Example Video:
https://www.youtube.com/watch?v=F6SDc5uMEgs&list=PL4fGSI1pDJn5FhDrWnRp2NLzJCoPliNgT&index=11
Screen Shot 2022-12-12 at 20 17 25

In the latest YouTube design, the music information is captured with song title and author. just check whether these two information both appear in the video title. If both appear, then genius can highly able to get the correct and unique result.
I think this can be the first priority on top of the current method.

I already have the js code to get the song title and song author.

Regarding these three points, please let me know what do you want.


Point 1.
(Still some fine tuning for light theme colors)


Point 2.
(Still some fine tuning for light theme colors)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.