aboutsummaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authorLibravatar Renard 2019-04-02 20:15:22 -0300
committerLibravatar Renard 2019-04-02 20:15:22 -0300
commit96c38d09a549ccc2887e83ff17107db1ace08e8a (patch)
treedc93ff613be4b4b331b076d8e465cffb0324ed1f /static/js
parentfd7a16dd0c1e81db7f3282b0518b248ebb374377 (diff)
parent8c5281cea797d2004087adf7642c5b8447e1b5f9 (diff)
downloadweabot-96c38d09a549ccc2887e83ff17107db1ace08e8a.tar.gz
weabot-96c38d09a549ccc2887e83ff17107db1ace08e8a.tar.xz
weabot-96c38d09a549ccc2887e83ff17107db1ace08e8a.zip
Merge branch 'master' of https://git.bienvenidoainternet.org/priv/www
Diffstat (limited to 'static/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);