cvzi / genius-lyrics-userscript

A userscript library to show lyrics from genius.com on other websites
GNU General Public License v3.0
14 stars 5 forks source link

Picture-in-Picture / Always-on-top window #53

Open cvzi opened 1 year ago

cvzi commented 1 year ago

In Chrome 111+ it's possible to show an always-on-top window with HTML content, previously only a video could be shown like this. This could be used to show the lyrics even if Youtube/Spotify tab is in the background.

A website that uses this: https://lazy-guy.github.io/tomodoro/index.html

cyfung1031 commented 1 year ago

Please be reminded that PIP requires user-interaction. You cannot suddenly popup that window without user clicking. (like auto lyrics)

And Firefox nevers support PIP.

cyfung1031 commented 1 year ago

YouTube uses popup window to do such kind of feature.

window.open(
  'https://github.com/cvzi/genius-lyrics-userscript/issues/53',
  '0.a.random.name', 
  'menubar=0,location=0,scrollbars=0,toolbar=0,width=600,height=600'
);
Screen Shot 2023-05-11 at 19 34 09

This will create a window object and you can use postMessage and addEventListener('message', ...) to communicate with the main window. You can use that robots.txt to hack your script in that window, by detecting the window.name