Fextralife Remove Twitch and Fix Layout

Removes twitch stream and fix layout for better readability.

目前为 2023-03-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fextralife Remove Twitch and Fix Layout
  3. // @namespace https://github.com/Dwyriel
  4. // @version 1.0
  5. // @description Removes twitch stream and fix layout for better readability.
  6. // @author Dwyriel
  7. // @license MIT
  8. // @match https://*.fextralife.com/*
  9. // @grant none
  10. // @homepageURL https://github.com/Dwyriel/Fextralife-Enhancements
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. const minMargin = 16, snapWidth = 480, desktopWidth = 1200, largeMobile = 768, maxMargin = 73.5 - minMargin;
  16. document.getElementById("sidebar-wrapper")?.remove();
  17. document.getElementById("wrapper").style.paddingLeft = "0px";
  18. let fexMain = document.querySelector(".fex-main");
  19. fexMain.style = "max-width: 1024px;";
  20. const fixLayout = () => {
  21. let windowWidth = window.innerWidth;
  22. let marginSize = "0px";
  23. if (windowWidth > desktopWidth)
  24. marginSize = "auto";
  25. else if (windowWidth >= largeMobile)
  26. marginSize = `${((windowWidth - largeMobile) / (desktopWidth - largeMobile) * maxMargin) + minMargin}px`;
  27. else if (windowWidth > snapWidth)
  28. marginSize = `${minMargin}px`;
  29. fexMain.style.marginLeft = marginSize;
  30. fexMain.style.marginRight = marginSize;
  31. };
  32. fixLayout();
  33. window.addEventListener('resize', () => fixLayout());
  34. })();