Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name [IIchan] Padoru Padoru 2021
- // @version 2.0
- // @icon https://i.fiery.me/FwdBW.gif
- // @namespace http://iichan.hk/
- // @license MIT
- // @description Add Padoru Chibi gifs under /b/ post form
- // @author Cirno
- // @match http://iichan.hk/*
- // @match https://iichan.hk/*
- // @grant none
- // ==/UserScript==
- function animateChibi(event){
- var element = event.target;
- if(typeof(element.src) != 'undefined' && element.hasAttribute('framesRunning')) {
- switch(element.src) {
- case element.getAttribute('framesStill'):
- element.src = element.getAttribute('framesRunning');
- break;
- case element.getAttribute('framesRunning'):
- element.src = element.getAttribute('framesStill');
- break;
- default:
- if(element.src.indexOf('/b/') != -1){
- if(element.src.indexOf(element.getAttribute('framesStill')) != -1){
- element.src = element.getAttribute('framesRunning');
- } else if(element.src.indexOf(element.getAttribute('framesRunning')) != -1){
- element.src = element.getAttribute('framesStill');
- }
- }
- break;
- }
- }
- }
- function init(){
- if(typeof(document.contentType) != 'undefined' && document.contentType != 'text/html') return;
- if(document.location.href.indexOf("/b/") != -1)
- {
- /* https://safe.fiery.me/a/LsiVxjLH
- originally from http://iichan.hk/b/res/5090803.html
- */
- var still =
- [
- "https://i.fiery.me/FwdBW.gif", /* Chiyo */
- "https://i.fiery.me/oMEz2.gif", /* Cirno */
- "https://i.fiery.me/gKGjW.gif", /* CT */
- "https://i.fiery.me/dXMA7.gif" /* Hurma */
- ];
- var running =
- [
- "https://i.fiery.me/9LOei.gif", /* Chiyo */
- "https://i.fiery.me/bbVeY.gif", /* Cirno */
- "https://i.fiery.me/0mW4T.gif", /* CT */
- "https://i.fiery.me/cTvHf.gif" /* Hurma */
- ];
- var form = document.getElementById("postform");
- if(!form) return;
- if(document.getElementById("chibisTable")) return;
- var styleStr = document.createElement('style');
- styleStr.innerHTML = '#iichan-quick-reply-form #chibisTable {display: none} #de-win-reply #chibisTable {display: none}';
- document.getElementsByTagName('head')[0].appendChild(styleStr);
- var newTable = document.createElement("table");
- newTable.setAttribute('id', 'chibisTable');
- var imageElements = [];
- var innerHtml = "<tbody><tr>";
- for (var i=0; i < still.length; i++)
- {
- var image = document.createElement("img");
- image.setAttribute('style', "cursor: pointer;");
- image.setAttribute('framesStill', still[i]);
- image.setAttribute('framesRunning', running[i]);
- image.setAttribute('src', still[i]);
- image.addEventListener('click', animateChibi);
- imageElements.push(image);
- innerHtml += "<td></td>";
- }
- newTable.innerHTML = innerHtml + "</tr></tbody>";
- var imgCells = newTable.getElementsByTagName('td');
- for (var i = 0; i < imgCells.length; ++i) {
- imgCells[i].appendChild(imageElements[i]);
- }
- form.appendChild(newTable);
- }
- }
- init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement