diff options
Diffstat (limited to 'static/js')
-rw-r--r-- | static/js/shobon.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/static/js/shobon.js b/static/js/shobon.js index b4e48f6..522dbe1 100644 --- a/static/js/shobon.js +++ b/static/js/shobon.js @@ -82,6 +82,11 @@ function shobon() { if(localStorage.getItem("shobon_navbar") == "true") { fixedNav(); } + // incluye imgur + if(localStorage.getItem("shobon_embedimg") == "true") { + embedImg(reply); + } + } if (newRepliesInThread > 0 && !inThread) { thread.getElementsByClassName("threadlinks")[0].innerHTML += "<span onClick='localStorage.setItem(\"" + boardName + "_" + threadId + "\" , " + lastReplyN + "); this.hidden = true;' style='font-weight: bold; background: #81a2be; padding: 5px; border-radius: 5px; float: right; margin-bottom: 10px;'>Marcar como leido</span>"; @@ -239,6 +244,7 @@ function shobonSettings(e) { p.appendChild(createCheckbox("shobon_on", "<b>Activar extensión</b>", true)); p.appendChild(createCheckbox("shobon_navbar", "Fijar barra superior", false)); p.appendChild(createCheckbox("shobon_ids", "Colorear IDs", true)); + p.appendChild(createCheckbox("shobon_embedimg", "Incluir imágenes de imgur", false)); p.appendChild(createCheckbox("shobon_newposts", "Destacar mensajes nuevos", false)); p.appendChild(createCheckbox("shobon_country", "Reemplazar códigos de país por nombres", false)); p.appendChild(createCheckbox("shobon_time", "Convertir fechas a hora local", true)); @@ -364,6 +370,20 @@ function paintIds(reply) { } } +function embedImg(reply) { + var links = reply.getElementsByTagName("a"); + for(i=0;i<links.length;i++) { + if(links[i].href.startsWith("https://i.imgur.com")) { + var url = links[i].href; + var ext = url.lastIndexOf('.'); + var thumb = document.createElement("img"); + thumb.src = url.slice(0, ext) + 's' + url.slice(ext); + links[i].appendChild(document.createElement("br")); + links[i].appendChild(thumb); + } + } +} + function toHex(str) { var hex = ''; for (var i = 0; i < str.length; i++) { @@ -405,4 +425,4 @@ function fixedNav() { } } -document.addEventListener('DOMContentLoaded', shobon, false);
\ No newline at end of file +document.addEventListener('DOMContentLoaded', shobon, false); |