Hardware Acceleration and Web Performance Enhancer

Toggle hardware acceleration and enhance web performance without logging users out

当前为 2024-10-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hardware Acceleration and Web Performance Enhancer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Toggle hardware acceleration and enhance web performance without logging users out
  6. // @author Tae
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const script = document.createElement('script');
  16. script.src = 'https://unpkg.com/quicklink@2.0.0/dist/quicklink.umd.js';
  17. script.onload = () => {
  18. try {
  19. quicklink.listen({
  20. origins: true,
  21. ignores: [
  22. (uri) => uri.includes('logout'),
  23. (uri) => uri.includes('login'),
  24. (uri) => uri.includes('account')
  25. ]
  26. });
  27. } catch (error) {
  28. console.error('Error loading Quicklink:', error);
  29. }
  30. };
  31. document.head.appendChild(script);
  32.  
  33. window.addEventListener('error', (event) => {
  34. console.error('Script error:', event.message);
  35. });
  36.  
  37. document.addEventListener('click', (event) => {
  38. const target = event.target;
  39. if (target.tagName === 'A' && (target.href.includes('logout') || target.href.includes('login') || target.href.includes('account'))) {
  40. event.preventDefault();
  41. console.warn('Prevented navigation to:', target.href);
  42. }
  43. });
  44.  
  45. // Prevent 503 errors
  46. setInterval(() => {
  47. if (navigator.sendBeacon) {
  48. navigator.sendBeacon('/keep-alive', '');
  49. } else {
  50. const xhr = new XMLHttpRequest();
  51. xhr.open('POST', '/keep-alive', true);
  52. xhr.send('');
  53. }
  54. }, 300000); // Send keep-alive request every 5 minutes
  55.  
  56. })();