Guest User

Padoru Padoru 2021.user.js

a guest
Dec 26th, 2020
30
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(typeof(document.contentType) != 'undefined' && document.contentType != 'text/html') return;
  29.  
  30.     if(document.location.href.indexOf("/b/") != -1)
  31.     {
  32.       /* https://safe.fiery.me/a/LsiVxjLH
  33.          originally from http://iichan.hk/b/res/5090803.html
  34.       */
  35.       var still =
  36.       [
  37.         "https://i.fiery.me/FwdBW.gif", /* Chiyo */
  38.         "https://i.fiery.me/oMEz2.gif", /* Cirno */
  39.         "https://i.fiery.me/gKGjW.gif", /* CT */
  40.         "https://i.fiery.me/dXMA7.gif"  /* Hurma */
  41.       ];
  42.  
  43.       var running =
  44.       [
  45.         "https://i.fiery.me/9LOei.gif", /* Chiyo */
  46.         "https://i.fiery.me/bbVeY.gif", /* Cirno */
  47.         "https://i.fiery.me/0mW4T.gif", /* CT */
  48.         "https://i.fiery.me/cTvHf.gif"  /* Hurma */
  49.       ];
  50.  
  51.       var form = document.getElementById("postform");
  52.       if(!form) return;
  53.       if(document.getElementById("chibisTable")) return;
  54.  
  55.       var styleStr = document.createElement('style');
  56.       styleStr.innerHTML = '#iichan-quick-reply-form #chibisTable {display: none} #de-win-reply #chibisTable {display: none}';
  57.       document.getElementsByTagName('head')[0].appendChild(styleStr);
  58.  
  59.       var newTable = document.createElement("table");
  60.       newTable.setAttribute('id', 'chibisTable');
  61.  
  62.       var imageElements = [];
  63.       var innerHtml = "<tbody><tr>";
  64.       for (var i=0; i < still.length; i++)
  65.       {
  66.         var image = document.createElement("img");
  67.         image.setAttribute('style', "cursor: pointer;");
  68.         image.setAttribute('framesStill', still[i]);
  69.         image.setAttribute('framesRunning', running[i]);
  70.         image.setAttribute('src', still[i]);
  71.         image.addEventListener('click', animateChibi);
  72.         imageElements.push(image);
  73.  
  74.         innerHtml += "<td></td>";
  75.       }
  76.       newTable.innerHTML = innerHtml + "</tr></tbody>";
  77.  
  78.       var imgCells = newTable.getElementsByTagName('td');
  79.       for (var i = 0; i < imgCells.length; ++i) {
  80.           imgCells[i].appendChild(imageElements[i]);
  81.       }
  82.  
  83.       form.appendChild(newTable);
  84.     }
  85. }
  86.  
  87. init();
  88.  
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment