aboutsummaryrefslogtreecommitdiff
path: root/static/js/shobon.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/shobon.js')
-rw-r--r--static/js/shobon.js35
1 files changed, 28 insertions, 7 deletions
diff --git a/static/js/shobon.js b/static/js/shobon.js
index b4e48f6..c9bce95 100644
--- a/static/js/shobon.js
+++ b/static/js/shobon.js
@@ -43,8 +43,7 @@ function shobon() {
}
var lastReplyN = replyList[replyList.length - 1].attributes["data-n"].value;
-
- if (localStorage.getItem(boardName + "_" + threadId) == null) {
+ if(localStorage.getItem("shobon_newposts") == "true" && localStorage.getItem(boardName + "_" + threadId) == null) {
localStorage.setItem(boardName + "_" + threadId, lastReplyN);
}
var lastSeen = localStorage.getItem(boardName + "_" + threadId);
@@ -75,13 +74,18 @@ function shobon() {
replaceCountryName(reply)
}
// colorea los id's
- if(localStorage.getItem("shobon_ids") != "false") {
+ if(localStorage.getItem("shobon_ids") == "true") {
paintIds(reply);
}
// deja la barra superior fija
if(localStorage.getItem("shobon_navbar") == "true") {
fixedNav();
}
+ // incluye imagenes
+ 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>";
@@ -96,10 +100,9 @@ function shobon() {
document.body.appendChild(banner);
}
- if (inThread) {
+ if(localStorage.getItem("shobon_newposts") == "true" && inThread) {
localStorage.setItem(boardName + "_" + threadId, lastReplyN);
}
-
}
function on_checked(e) {
@@ -238,7 +241,8 @@ function shobonSettings(e) {
var p = document.createElement("div");
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_ids", "Colorear IDs", false));
+ p.appendChild(createCheckbox("shobon_embedimg", "Incluir imágenes miniatura", 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 +368,23 @@ function paintIds(reply) {
}
}
+function embedImg(reply) {
+ var links = reply.getElementsByTagName("a");
+ for(i=0;i<links.length&&i<5;i++) {
+ var url = links[i].href;
+ if(url.startsWith("https://i.imgur.com")) {
+ var ext = url.lastIndexOf('.');
+ var thumburl = url.slice(0, ext) + 's' + url.slice(ext);
+ } else if(links[i].href.startsWith("https://pbs.twimg.com")) {
+ var thumburl = links[i].href + ":thumb";
+ } else continue;
+ var thumb = document.createElement("img");
+ thumb.src = thumburl;
+ 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 +426,4 @@ function fixedNav() {
}
}
-document.addEventListener('DOMContentLoaded', shobon, false); \ No newline at end of file
+document.addEventListener('DOMContentLoaded', shobon, false);