Kongregate 2.0 - Disable Animations

Disable animations from the new Kongregate homepage

  1. // ==UserScript==
  2. // @name Kongregate 2.0 - Disable Animations
  3. // @namespace com.ruudiluca.kongregate.disable.animations
  4. // @description Disable animations from the new Kongregate homepage
  5. // @version 0.1
  6. // @author Ruudiluca
  7. // @match https://www.kongregate.com/
  8. // @grant GM_addElement
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function executeScript() {
  17. let sliderRoot = document.getElementsByTagName('k-ticker-banner')[0];
  18. let sliderDom = sliderRoot?.shadowRoot;
  19.  
  20. if (!sliderDom) return setTimeout(executeScript, 100); // retry a bit later
  21.  
  22. let styles = `
  23. .ticker-banner__ticker {
  24. animation: initial !important;
  25. padding-left: initial !important;
  26. margin: auto !important;
  27. }
  28. `;
  29. GM_addElement(sliderDom, 'style', { textContent: styles });
  30.  
  31. }
  32.  
  33. executeScript();
  34.  
  35. function handleMutations(mutationsList, observer) {
  36. mutationsList.forEach(mutation => {
  37. if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
  38. [].slice.apply(mutation.addedNodes).filter(is_gif_image).map(freeze_gif);
  39. }
  40. });
  41. }
  42.  
  43. const observer = new MutationObserver(handleMutations);
  44. observer.observe(document, { childList: true, subtree: true });
  45.  
  46. function is_gif_image(i) {
  47. return /^(?!data:).*\.gif/i.test(i.src);
  48. }
  49.  
  50. function freeze_gif(i) {
  51. var c = document.createElement('canvas');
  52. var w = c.width = i.width;
  53. var h = c.height = i.height;
  54. c.getContext('2d').drawImage(i, 0, 0, w, h);
  55. try {
  56. i.src = c.toDataURL("image/gif"); // if possible, retain all css aspects
  57. } catch(e) { // cross-domain -- mimic original with all its tag attributes
  58. for (var j = 0, a; a = i.attributes[j]; j++)
  59. c.setAttribute(a.name, a.value);
  60. i.parentNode.replaceChild(c, i);
  61. }
  62. }
  63. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址