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.1
  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://i.imgur.com/Kt673Kv.png','https://i.imgur.com/5KHuSxr.png','https://i.imgur.com/Nobrqcr.png','https://i.imgur.com/0E5QkVZ.png','https://i.imgur.com/ChuPbAz.png','https://i.imgur.com/Wxzjoul.png','https://i.imgur.com/0H6gG1j.png','https://i.imgur.com/kaNQoIs.png'],
  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. })();