NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name komica_extend // @namespace https://openuserjs.org/ // @version 3 // @description Welcome to the Axis Cult // @author Zesta // @match https://aqua.komica.org/* // @license MIT // @grant none // ==/UserScript== (function() { let doc_array = document.querySelectorAll('#threads > .thread'); let title_array = document.querySelectorAll('.post.threadpost > .post-head'); // A02 管理失當,K島無法刪除文章 // 有需要繼續使用,請自行修正程式碼 //runit(); function runit(){ for(let i = 0, len = title_array.length ; i < len ; i++){ let title = title_array[i]; let link = document.createElement('a'); link.href = 'javascript: void(0);'; link.innerHTML = '展開'; link.onclick = function() { if(this.innerHTML == '展開'){ extend(i); this.innerHTML = '收合'; }else{ packUp(i); this.innerHTML = '展開'; } }; title.append('['); title.append(link); title.append(']'); } } function extend(j){ let doc = doc_array[j].querySelectorAll('a.file-thumb'); for(let i=0, len = doc.length ; i < len ; i++){ doc[i].style.display = 'none'; let quote = doc[i].parentNode.querySelectorAll('a.file-thumb')[0].nextSibling; let src = doc[i].href; let ddiv = document.createElement('div'); ddiv.className = '-expanded'; ddiv.style = 'margin: 0.2em; display:block;'; ddiv.onclick = function(){ this.remove(); doc[i].style.display = ''; }; ddiv.innerHTML = '<img class="expanded-element expanded-close" style="max-width:100%; cursor:pointer;" src='+src+'>'; quote.parentNode.insertBefore(ddiv,quote); } } function packUp(j){ let doc = doc_array[j].querySelectorAll('a.file-thumb'); let expand = doc_array[j].querySelectorAll('.-expanded'); for(let i=0, len = expand.length ; i < len ; i++){ if(doc[i]) doc[i].style.display = ''; if(expand[i]) expand[i].remove(); } } })();