SHOW:
|
|
- or go back to the newest paste.
| 1 | // ==UserScript== | |
| 2 | - | // @name Padoru Padoru 2021 |
| 2 | + | // @name [IIchan] Padoru Padoru 2021 |
| 3 | // @version 2.0 | |
| 4 | // @icon https://i.fiery.me/FwdBW.gif | |
| 5 | - | // @namespace * |
| 5 | + | // @namespace http://iichan.hk/ |
| 6 | - | // @include http://iichan.hk/* |
| 6 | + | // @license MIT |
| 7 | - | // @include http://*.iichan.hk/* |
| 7 | + | // @description Add Padoru Chibi gifs under /b/ post form |
| 8 | - | // @include https://iichan.hk/* |
| 8 | + | // @author Cirno |
| 9 | - | // @include https://*.iichan.hk/* |
| 9 | + | // @match http://iichan.hk/* |
| 10 | // @match https://iichan.hk/* | |
| 11 | // @grant none | |
| 12 | // ==/UserScript== | |
| 13 | ||
| 14 | ||
| 15 | function animateChibi(event){
| |
| 16 | var element = event.target; | |
| 17 | ||
| 18 | if(typeof(element.src) != 'undefined' && element.hasAttribute('framesRunning')) {
| |
| 19 | switch(element.src) {
| |
| 20 | case element.getAttribute('framesStill'):
| |
| 21 | element.src = element.getAttribute('framesRunning');
| |
| 22 | break; | |
| 23 | case element.getAttribute('framesRunning'):
| |
| 24 | element.src = element.getAttribute('framesStill');
| |
| 25 | break; | |
| 26 | default: | |
| 27 | if(element.src.indexOf('/b/') != -1){
| |
| 28 | if(element.src.indexOf(element.getAttribute('framesStill')) != -1){
| |
| 29 | element.src = element.getAttribute('framesRunning');
| |
| 30 | } else if(element.src.indexOf(element.getAttribute('framesRunning')) != -1){
| |
| 31 | element.src = element.getAttribute('framesStill');
| |
| 32 | } | |
| 33 | } | |
| 34 | break; | |
| 35 | } | |
| 36 | } | |
| 37 | } | |
| 38 | ||
| 39 | function init(){
| |
| 40 | if(typeof(document.contentType) != 'undefined' && document.contentType != 'text/html') return; | |
| 41 | ||
| 42 | if(document.location.href.indexOf("/b/") != -1)
| |
| 43 | {
| |
| 44 | /* https://safe.fiery.me/a/LsiVxjLH | |
| 45 | originally from http://iichan.hk/b/res/5090803.html | |
| 46 | */ | |
| 47 | var still = | |
| 48 | [ | |
| 49 | "https://i.fiery.me/FwdBW.gif", /* Chiyo */ | |
| 50 | "https://i.fiery.me/oMEz2.gif", /* Cirno */ | |
| 51 | "https://i.fiery.me/gKGjW.gif", /* CT */ | |
| 52 | "https://i.fiery.me/dXMA7.gif" /* Hurma */ | |
| 53 | ]; | |
| 54 | ||
| 55 | var running = | |
| 56 | [ | |
| 57 | "https://i.fiery.me/9LOei.gif", /* Chiyo */ | |
| 58 | "https://i.fiery.me/bbVeY.gif", /* Cirno */ | |
| 59 | "https://i.fiery.me/0mW4T.gif", /* CT */ | |
| 60 | "https://i.fiery.me/cTvHf.gif" /* Hurma */ | |
| 61 | ]; | |
| 62 | ||
| 63 | var form = document.getElementById("postform");
| |
| 64 | if(!form) return; | |
| 65 | if(document.getElementById("chibisTable")) return;
| |
| 66 | ||
| 67 | var styleStr = document.createElement('style');
| |
| 68 | styleStr.innerHTML = '#iichan-quick-reply-form #chibisTable {display: none} #de-win-reply #chibisTable {display: none}';
| |
| 69 | document.getElementsByTagName('head')[0].appendChild(styleStr);
| |
| 70 | ||
| 71 | var newTable = document.createElement("table");
| |
| 72 | newTable.setAttribute('id', 'chibisTable');
| |
| 73 | ||
| 74 | var imageElements = []; | |
| 75 | var innerHtml = "<tbody><tr>"; | |
| 76 | for (var i=0; i < still.length; i++) | |
| 77 | {
| |
| 78 | var image = document.createElement("img");
| |
| 79 | image.setAttribute('style', "cursor: pointer;");
| |
| 80 | image.setAttribute('framesStill', still[i]);
| |
| 81 | image.setAttribute('framesRunning', running[i]);
| |
| 82 | image.setAttribute('src', still[i]);
| |
| 83 | image.addEventListener('click', animateChibi);
| |
| 84 | imageElements.push(image); | |
| 85 | ||
| 86 | innerHtml += "<td></td>"; | |
| 87 | } | |
| 88 | newTable.innerHTML = innerHtml + "</tr></tbody>"; | |
| 89 | ||
| 90 | var imgCells = newTable.getElementsByTagName('td');
| |
| 91 | for (var i = 0; i < imgCells.length; ++i) {
| |
| 92 | imgCells[i].appendChild(imageElements[i]); | |
| 93 | } | |
| 94 | ||
| 95 | form.appendChild(newTable); | |
| 96 | } | |
| 97 | } | |
| 98 | ||
| 99 | init(); | |
| 100 | ||
| 101 | ||
| 102 |