Hardware Acceleration and Web Performance Enhancer

Toggle hardware acceleration and enhance web performance

当前为 2024-08-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hardware Acceleration and Web Performance Enhancer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description Toggle hardware acceleration and enhance web performance
  6. // @author Tae
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Load Quicklink
  16. const script = document.createElement('script');
  17. script.src = 'https://unpkg.com/quicklink@2.0.0/dist/quicklink.umd.js';
  18. script.onload = () => {
  19. try {
  20. quicklink.listen({
  21. origins: true, // Only prefetch links from the same origin
  22. ignores: [ // Ignore links that might cause issues
  23. (uri) => uri.includes('logout'),
  24. (uri) => uri.includes('login'),
  25. (uri) => uri.includes('account')
  26. ]
  27. });
  28. } catch (error) {
  29. console.error('Error loading Quicklink:', error);
  30. }
  31. };
  32. document.head.appendChild(script);
  33.  
  34. // Additional error handling
  35. window.addEventListener('error', (event) => {
  36. console.error('Script error:', event.message);
  37. });
  38.  
  39. // Prevent logging out users
  40. document.addEventListener('click', (event) => {
  41. const target = event.target;
  42. if (target.tagName === 'A' && (target.href.includes('logout') || target.href.includes('login') || target.href.includes('account'))) {
  43. event.preventDefault();
  44. console.warn('Prevented navigation to:', target.href);
  45. }
  46. });
  47. })();