double-touched to enter fullscreen

I AM THE WORLD

  1. // ==UserScript==
  2. // @name double-touched to enter fullscreen
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description I AM THE WORLD
  6. // @author You
  7. // @match *://*.douyin.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=douyin.com
  9. // @grant GM_registerMenuCommand
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. let ref_url = 'https://www.douyin.com/?is_from_mobile_home=1&recommend=1';
  16. if(window.location.href == 'https://www.douyin.com/home') {
  17. window.location.href = ref_url;
  18. };
  19.  
  20. function toggleFullscreen() {
  21. let videoElement = document.querySelector("video"); // Target the video element
  22.  
  23. if (!document.fullscreenElement) {
  24. if (videoElement.requestFullscreen) {
  25. videoElement.requestFullscreen();
  26. } else if (videoElement.mozRequestFullScreen) { // Firefox
  27. videoElement.mozRequestFullScreen();
  28. } else if (videoElement.webkitRequestFullscreen) { // Chrome, Safari, Opera
  29. videoElement.webkitRequestFullscreen();
  30. } else if (videoElement.msRequestFullscreen) { // IE/Edge
  31. videoElement.msRequestFullscreen();
  32. }
  33. } else {
  34. if (document.exitFullscreen) {
  35. document.exitFullscreen();
  36. } else if (document.mozCancelFullScreen) { // Firefox
  37. document.mozCancelFullScreen();
  38. } else if (document.webkitExitFullscreen) { // Chrome, Safari, Opera
  39. document.webkitExitFullscreen();
  40. } else if (document.msExitFullscreen) { // IE/Edge
  41. document.msExitFullscreen();
  42. }
  43. }
  44. }
  45.  
  46. // Register the menu command to toggle fullscreen
  47. GM_registerMenuCommand('Toggle Fullscreen', toggleFullscreen);
  48.  
  49.  
  50. // Hide the DanMu Data
  51. const observer = new MutationObserver(() => {
  52. document.querySelectorAll('.danmu').forEach(element => {
  53. element.style.display = 'none';
  54. });
  55.  
  56. });
  57.  
  58. // Configure the observer to watch for changes in the entire document
  59. observer.observe(document, {
  60. childList: true,
  61. subtree: true,
  62. });
  63.  
  64. window.onload = () => {
  65. let btn = document.createElement("button");
  66. btn.innerHTML = "Let's Go";
  67. btn.id = "fullscreen";
  68. btn.style.position = "fixed"; // Stays in place while scrolling
  69. btn.style.top = "10px"; // Distance from the top
  70. btn.style.left = "10px"; // Distance from the left
  71. btn.style.padding = "10px 20px";
  72. btn.style.backgroundColor = "blue";
  73. btn.style.color = "white";
  74. btn.style.border = "none";
  75. btn.style.borderRadius = "5px";
  76. btn.style.cursor = "pointer";
  77. btn.style.zIndex = "9999"; // Ensures the button is in the front layer
  78.  
  79. // Add click event to redirect
  80. btn.onclick = function () {
  81. document.documentElement.webkitRequestFullscreen();
  82. document.getElementById('fullscreen').style.display = 'none'
  83. };
  84.  
  85. // Append button to the body
  86. document.body.appendChild(btn);
  87. }
  88. })();