Benjify

Turns all images on page to benjis

目前为 2024-07-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Benjify
  3. // @namespace Joshy2Saucy
  4. // @description Turns all images on page to benjis
  5. // @include *
  6. // @version 1.0
  7. // @license Joshy2Saucy
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. var Program = {
  12. // To add images: Google image search for the desired images, then run the following command in your browser console (tested in FF):
  13. // var output = ''; document.body.innerHTML.match(/(?=imgurl=)(.+?)(?=&)/g).map(function(value) {var url = encodeURIComponent(decodeURIComponent(decodeURIComponent(value)).replace('imgurl=', '').replace(/'/g, '\\\'')); if (url) output += '\'' + url + '\',';}); window.open('data:text/plain,' + output, '_blank', 'width=500,height=500,scrollbars=1');
  14. // Copy and paste the output below. Make sure the opening and closing []s are still there, and make sure the last line does not end with a comma.
  15. replacementImages: [
  16. 'https://cdn.discordapp.com/attachments/1071976037338067046/1249227844777807872/cEKy0ty.png?ex=6696a857&is=669556d7&hm=c41fbda855659a8685dcbdf0daa11fba27ec2129b3aa3057bd45ba843c3e0c59&'],
  17. loaded: false,
  18. changeBufferTimer: null,
  19.  
  20. main: function() {
  21. if (!this.loaded) {
  22. this.loaded = true;
  23. document.addEventListener('DOMSubtreeModified', this.domChanged, false);
  24. this.domChangedBuffered();
  25. }
  26. },
  27.  
  28. domChanged: function() {
  29. if (this.changeBufferTimer) {
  30. clearTimeout(this.changeBufferTimer);
  31. this.changeBufferTimer = null;
  32. }
  33. this.changeBufferTimer = setTimeout(this.domChangedBuffered.bind(this), 222); //-- 222 milliseconds
  34. },
  35.  
  36. domChangedBuffered: function() {
  37. var images = document.getElementsByTagName('img');
  38. for (var i = 0; i < images.length; i++) {
  39. images[i].src = this.replacementImages[Math.floor(Math.random() * this.replacementImages.length)];
  40. }
  41. }
  42. };
  43.  
  44. window.addEventListener('load', Program.main.bind(Program), false);
  45. })();