NERD Inserter

just enable it and see what happens

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

  1. // ==UserScript==
  2. // @name NERD Inserter
  3. // @namespace nerd-inserter
  4. // @homepageURL https://c2g.at
  5. // @description just enable it and see what happens
  6. // @author c2g_at
  7. // @match *://*.wikipedia.org/*
  8. // @match *://*.google.com/search*
  9. // @match *://*.stackoverflow.com/*
  10. // @match *://*.serverfault.com/*
  11. // @match *://*.superuser.com/*
  12. // @match *://*.stackexchange.com/*
  13. // @match *://*.mathoverflow.net/*
  14. // @match *://*.stackapps.com/*
  15. // @match *://*.askubuntu.com/*
  16. // @match *://*.github.com/*
  17. // @match *://*.github.io/*
  18. // @match *://*.udemy.com/*
  19. // @match *://*.freecodecamp.org/*
  20. // @match *://developers.mozilla.org/*
  21. // @match *://*.sololearn.com/*
  22.  
  23.  
  24. // @version 0.0.1.20240131234124
  25. // ==/UserScript==
  26. (function() {
  27. 'use strict';
  28.  
  29. var mouseX = 0;
  30. var mouseY = 0;
  31. document.addEventListener('mousemove', function(e) {
  32. mouseX = e.clientX;
  33. mouseY = e.clientY;
  34. });
  35.  
  36. function applyMouseForce(img) {
  37. var imgRect = img.getBoundingClientRect();
  38. var imgX = imgRect.left + imgRect.width / 2;
  39. var imgY = imgRect.top + imgRect.height / 2;
  40. var distX = mouseX - imgX;
  41. var distY = mouseY - imgY;
  42. var distance = Math.sqrt(distX * distX + distY * distY);
  43. var maxDistance = 100; // Max distance for interaction
  44.  
  45. if (distance < maxDistance) {
  46. var forceX = (maxDistance - distance) * (distX / distance);
  47. var forceY = (maxDistance - distance) * (distY / distance);
  48.  
  49. img.style.left = img.offsetLeft - forceX + 'px';
  50. img.style.bottom = parseInt(img.style.bottom, 10) - forceY + 'px';
  51. }
  52. }
  53.  
  54. function createFloatingImage(src) {
  55. var img = document.createElement('img');
  56. img.src = src;
  57.  
  58. var size = Math.random() * (120 - 50) + 50; // Size between 50px and 120px
  59. img.style.width = size + 'px';
  60. img.style.height = 'auto';
  61.  
  62. img.style.position = 'fixed';
  63. img.style.bottom = '-150px';
  64. img.style.left = Math.random() * window.innerWidth + 'px';
  65. img.style.zIndex = 9999;
  66. img.style.pointerEvents = 'none';
  67. var bottomPosition = -150;
  68. var leftPosition = parseInt(img.style.left, 10);
  69. var sway = 50;
  70. var swayDirection = 1;
  71.  
  72. var interval = setInterval(function() {
  73. bottomPosition += 2;
  74. img.style.bottom = bottomPosition + 'px';
  75.  
  76. if (leftPosition > window.innerWidth - size || leftPosition < 0) {
  77. swayDirection *= -1;
  78. }
  79. leftPosition += 0.5 * swayDirection;
  80. img.style.left = leftPosition + 'px';
  81.  
  82. if (bottomPosition > window.innerHeight + 150) {
  83. clearInterval(interval);
  84. img.remove();
  85. }
  86. applyMouseForce(img);
  87.  
  88. }, 50);
  89.  
  90. document.body.appendChild(img);
  91. }
  92.  
  93. var imageUrl = 'https://i.imgur.com/jXsXO6T.png';
  94.  
  95. // Create 25 floating images at random intervals
  96. for (var i = 0; i < 50; i++) {
  97. // Random delay between 0 to 10 seconds
  98. var delay = Math.random() * 10000;
  99. setTimeout(function() {
  100. createFloatingImage(imageUrl);
  101. }, delay);
  102. }
  103. })();