Guest User

Padoru Padoru 2021.user.js

a guest
Dec 26th, 2020
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Padoru Padoru 2021
  3. // @version        2.0
  4. // @icon           https://i.fiery.me/FwdBW.gif
  5. // @namespace      *
  6. // @include        http://iichan.hk/*
  7. // @include        http://*.iichan.hk/*
  8. // @include        https://iichan.hk/*
  9. // @include        https://*.iichan.hk/*
  10. // ==/UserScript==
  11.  
  12. function animateChibi(event){
  13.     var element = event.target;
  14.  
  15.     if(typeof(element.src) != 'undefined' && element.hasAttribute('framesRunning')) {
  16.         switch(element.src) {
  17.             case element.getAttribute('framesStill'):
  18.                 element.src = element.getAttribute('framesRunning');
  19.                 break;
  20.             case element.getAttribute('framesRunning'):
  21.                 element.src = element.getAttribute('framesStill');
  22.                 break;
  23.         }
  24.     }
  25. }
  26.  
  27. function init(){
  28.     if(document.location.href.indexOf("/b/") != -1)
  29.     {
  30.       /* https://safe.fiery.me/a/LsiVxjLH
  31.          originally from http://iichan.hk/b/res/5090803.html
  32.       */
  33.       var still =
  34.       [
  35.         "https://i.fiery.me/FwdBW.gif", /* Chiyo */
  36.         "https://i.fiery.me/oMEz2.gif", /* Cirno */
  37.         "https://i.fiery.me/gKGjW.gif", /* CT */
  38.         "https://i.fiery.me/dXMA7.gif"  /* Hurma */
  39.       ];
  40.  
  41.       var running =
  42.       [
  43.         "https://i.fiery.me/9LOei.gif", /* Chiyo */
  44.         "https://i.fiery.me/bbVeY.gif", /* Cirno */
  45.         "https://i.fiery.me/0mW4T.gif", /* CT */
  46.         "https://i.fiery.me/cTvHf.gif"  /* Hurma */
  47.       ];
  48.  
  49.       var form = document.getElementById("postform");
  50.       if(!form) return;
  51.       if(document.getElementById("chibisTable")) return;
  52.  
  53.       var styleStr = document.createElement('style');
  54.       styleStr.innerHTML = '#iichan-quick-reply-form #chibisTable {display: none} #de-win-reply #chibisTable {display: none}';
  55.       document.getElementsByTagName('head')[0].appendChild(styleStr);
  56.  
  57.       var newTable = document.createElement("table");
  58.       newTable.setAttribute('id', 'chibisTable');
  59.  
  60.       var imageElements = [];
  61.       var innerHtml = "<tbody><tr>";
  62.       for (var i=0; i < still.length; i++)
  63.       {
  64.         var image = document.createElement("img");
  65.         image.setAttribute('style', "cursor: pointer;");
  66.         image.setAttribute('framesStill', still[i]);
  67.         image.setAttribute('framesRunning', running[i]);
  68.         image.setAttribute('src', still[i]);
  69.         image.addEventListener('click', animateChibi);
  70.         imageElements.push(image);
  71.  
  72.         innerHtml += "<td></td>";
  73.       }
  74.       newTable.innerHTML = innerHtml + "</tr></tbody>";
  75.  
  76.       var imgCells = newTable.getElementsByTagName('td');
  77.       for (var i = 0; i < imgCells.length; ++i) {
  78.           imgCells[i].appendChild(imageElements[i]);
  79.       }
  80.  
  81.       form.appendChild(newTable);
  82.     }
  83. }
  84.  
  85. init();
  86.  
  87.  
  88.  
Advertisement
Add Comment
Please, Sign In to add comment