A Chrome extension that hides all YouTube UI except for your video
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { buildLaunchContainer, buildRefinedPage } from './templates';
  2. import './style.css';
  3. const run = async () => {
  4. const $ = (selector) => document.querySelector(selector);
  5. const fetchParam = (name) => {
  6. const param = window.location.search
  7. .substr(1)
  8. .split('&')
  9. .map((param) => param.split('='))
  10. .find((param) => param[0] === name);
  11. return param ? param[1] : undefined;
  12. };
  13. const refinePage = (page) => ($('html').innerHTML = page);
  14. const videoId = fetchParam('v');
  15. const refineImmediately = fetchParam('refined') ? true : false;
  16. if (videoId !== undefined) {
  17. if (refineImmediately) {
  18. refinePage(buildRefinedPage(videoId));
  19. } else {
  20. const launchContainer = document.createElement('div');
  21. launchContainer.innerHTML = buildLaunchContainer(videoId);
  22. document.body.append(launchContainer);
  23. const launchButton = $('#refined-youtube-launch-button');
  24. const launchCloseButton = $('#refined-youtube-launch-close-button');
  25. launchButton.addEventListener('click', () =>
  26. refinePage(buildRefinedPage(videoId))
  27. );
  28. launchCloseButton.addEventListener('click', () => {
  29. const launchContainer = $('#refined-youtube-launch-container');
  30. launchContainer.style.opacity = 0;
  31. setTimeout(() => {
  32. launchContainer.remove();
  33. }, 1000);
  34. });
  35. }
  36. }
  37. };
  38. run();