Added features to automatically load all messages in a thread and enable the enableLoadingDraftMessages flag
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e97e6d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+console_inject_deprecated.js
diff --git a/_locales/ca/messages.json b/_locales/ca/messages.json
index 871cfb0..d44063b 100644
--- a/_locales/ca/messages.json
+++ b/_locales/ca/messages.json
@@ -12,7 +12,11 @@
"description": "Feature checkbox in the options page"
},
"options_thread": {
- "message": "Activa el scroll infinit dins dels fils.",
+ "message": "Carrega automàticament missatges en grups petits quan facis scroll per un fil.",
+ "description": "Feature checkbox in the options page"
+ },
+ "options_threadall": {
+ "message": "Carrega automàticament tots els missatges de cop quan facis scroll per un fil.",
"description": "Feature checkbox in the options page"
},
"options_enhancements": {
@@ -27,6 +31,10 @@
"message": "Redirigeix tots els fils oberts a TW a la Consola de la Comunitat.",
"description": "Feature checkbox in the options page"
},
+ "options_loaddrafts": {
+ "message": "Activa la <i>flag><\/i> <code class=\"help\" title=\"Aquesta flag permet a la Consola de la Comunitat carregar una resposta automàticament desada anteriorment quan obres un fil i fas clic al botó de respondre.\">enableLoadingDraftMessages<\/code> de la Consola de la Comunitat.",
+ "description": "Feature checkbox in the options page"
+ },
"options_experimental_label": {
"message": "(experimental)",
"description": "Label which is placed next to an option to indicate that it may not work well or may break at any time"
@@ -47,4 +55,4 @@
"message": "Historial de publicacions",
"description": "Link shown in a user profile (in TW and the Community Console) which points to a search showing the user's posts and messages"
}
-}
+}
\ No newline at end of file
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 905c210..2592504 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -12,7 +12,11 @@
"description": "Feature checkbox in the options page"
},
"options_thread": {
- "message": "Enable infinite scrolling inside threads.",
+ "message": "Automatically load batches of messages inside threads when scrolling down.",
+ "description": "Feature checkbox in the options page"
+ },
+ "options_threadall": {
+ "message": "Automatically load all messages at once inside threads when scrolling down.",
"description": "Feature checkbox in the options page"
},
"options_enhancements": {
@@ -27,6 +31,10 @@
"message": "Redirect all threads opened in TW to the Community Console.",
"description": "Feature checkbox in the options page"
},
+ "options_loaddrafts":{
+ "message": "Activate the <code class=\"help\" title=\"This flag allows the Community Console to load a previously autosaved reply when loading a thread and clicking the reply button.\">enableLoadingDraftMessages</code> Community Console flag.",
+ "description": "Feature checkbox in the options page"
+ },
"options_experimental_label": {
"message": "(experimental)",
"description": "Label which is placed next to an option to indicate that it may not work well or may break at any time"
diff --git a/_locales/es/messages.json b/_locales/es/messages.json
index 328cff1..97adb10 100644
--- a/_locales/es/messages.json
+++ b/_locales/es/messages.json
@@ -12,7 +12,11 @@
"description": "Feature checkbox in the options page"
},
"options_thread": {
- "message": "Activa el scroll infinito dentro de los hilos.",
+ "message": "Carga automáticamente mensajes en grupos pequeños cuando hagas scroll por un hilo.",
+ "description": "Feature checkbox in the options page"
+ },
+ "options_threadall": {
+ "message": "Carga automáticamente todos los mensajes a la vez cuando hagas scroll por un hilo.",
"description": "Feature checkbox in the options page"
},
"options_enhancements": {
@@ -27,6 +31,10 @@
"message": "Redirige todos los hilos abiertos en TW a la Consola de la Comunidad.",
"description": "Feature checkbox in the options page"
},
+ "options_loaddrafts":{
+ "message": "Activa la <i>flag></i> <code class=\"help\" title=\"Esta flag permite a la Consola de la Comunidad cargar una respuesta previamente autoguardada cuando abres un hilo y haces clic en el botón de responder.\">enableLoadingDraftMessages</code> de la Consola de la Comunidad.",
+ "description": "Feature checkbox in the options page"
+ },
"options_experimental_label": {
"message": "(experimental)",
"description": "Label which is placed next to an option to indicate that it may not work well or may break at any time"
diff --git a/background.js b/background.js
index de7c93e..d518431 100644
--- a/background.js
+++ b/background.js
@@ -5,9 +5,11 @@
var defaultOptions = {
"list": true,
"thread": true,
+ "threadall": false,
"fixedtoolbar": false,
"redirect": false,
- "history": false
+ "history": false,
+ "loaddrafts": false
};
function cleanUpOptions() {
diff --git a/console_inject.js b/console_inject.js
index 0f77085..7c0d339 100644
--- a/console_inject.js
+++ b/console_inject.js
@@ -13,6 +13,10 @@
intersectionObserver.observe(node.querySelector(".load-more-button"));
}
+ if (options.threadall && node.classList.contains("load-more-bar")) {
+ intersectionObserver.observe(node.querySelector(".load-all-button"));
+ }
+
if (options.history && ("parentNode" in node) && node.parentNode !== null && ("tagName" in node.parentNode) && node.parentNode.tagName == "EC-USER") {
var nameElement = node.querySelector(".name span");
if (nameElement !== null) {
diff --git a/console_inject_start.js b/console_inject_start.js
new file mode 100644
index 0000000..6036464
--- /dev/null
+++ b/console_inject_start.js
@@ -0,0 +1,23 @@
+/*var forums = ["youtube"];
+
+for (forum of startup[1][2]) {
+ if (forums.includes(forum[2][14])) {
+ forum[3] = {
+ "1": {
+ "2": "1551129889541098",
+ "3": 100
+ },
+ "2": {
+ "7": true
+ }
+ }
+ }
+}*/
+
+chrome.storage.sync.get(null, function(items) {
+ if (items.loaddrafts) {
+ var startup = JSON.parse(document.querySelector("html").getAttribute("data-startup"));
+ startup[4][13] = true;
+ document.querySelector("html").setAttribute("data-startup", JSON.stringify(startup));
+ }
+});
diff --git a/manifest.json b/manifest.json
index 55779eb..d1ee5e0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -13,6 +13,11 @@
"js": ["console_inject.js"]
},
{
+ "matches": ["https://support.google.com/s/community*"],
+ "js": ["console_inject_start.js"],
+ "run_at": "document_start"
+ },
+ {
"matches": ["https://support.google.com/*/threads*"],
"js": ["forum_inject.js"]
},
diff --git a/options.css b/options.css
new file mode 100644
index 0000000..a6fb4de
--- /dev/null
+++ b/options.css
@@ -0,0 +1,4 @@
+.help {
+ cursor: help;
+ border-bottom: dashed 1px gray;
+}
diff --git a/options.html b/options.html
index 8e4bd46..6b120c5 100644
--- a/options.html
+++ b/options.html
@@ -3,17 +3,20 @@
<head>
<meta charset="utf-8">
<title>Options</title>
+ <link rel="stylesheet" href="options.css">
</head>
<body>
<p>
<input type="checkbox" id="list"> <label for="list" data-i18n="list"></label><br>
- <input type="checkbox" id="thread"> <label for="thread" data-i18n="thread"></label>
+ <input type="checkbox" id="thread"> <label for="thread" data-i18n="thread"></label><br>
+ <input type="checkbox" id="threadall"> <label for="threadall" data-i18n="threadall"></label>
</p>
<h4 data-i18n="enhancements"></h4>
<p>
<input type="checkbox" id="fixedtoolbar"> <label for="fixedtoolbar" data-i18n="fixedtoolbar"></label><br>
<input type="checkbox" id="redirect"> <label for="redirect" data-i18n="redirect"></label> <span style="color: gray;" data-i18n="experimental_label"></span><br>
- <input type="checkbox" id="history"> <label for="history" data-i18n="history"></label>
+ <input type="checkbox" id="history"> <label for="history" data-i18n="history"></label><br>
+ <input type="checkbox" id="loaddrafts"> <label for="loaddrafts" data-i18n="loaddrafts"></label> <span style="color: gray;" data-i18n="experimental_label"></span>
</p>
<p style="text-align: center;"><button id="save" data-i18n="save"></button></p>
<script src="options.js"></script>
diff --git a/options.js b/options.js
index 266a28b..026776c 100644
--- a/options.js
+++ b/options.js
@@ -5,9 +5,11 @@
var defaultOptions = {
"list": true,
"thread": true,
+ "threadall": false,
"fixedtoolbar": false,
"redirect": false,
- "history": false
+ "history": false,
+ "loaddrafts": false
};
function cleanUpOptions(options) {
@@ -39,14 +41,19 @@
}
function i18n() {
- var messages = ["list", "thread", "enhancements", "fixedtoolbar", "redirect", "experimental_label", "history", "save"];
+ var messages = ["list", "thread", "threadall", "enhancements", "fixedtoolbar", "redirect", "loaddrafts", "experimental_label", "history", "save"];
messages.forEach(function(msg) {
- console.log(msg);
- document.querySelector("[data-i18n=\""+msg+"\"]").innerHTML = chrome.i18n.getMessage("options_"+msg);
+ document.querySelectorAll("[data-i18n=\""+msg+"\"]").forEach(el => el.innerHTML = chrome.i18n.getMessage("options_"+msg));
});
}
+function thread() {
+ if (document.querySelector("#thread").checked && document.querySelector("#threadall").checked) {
+ document.querySelector("#"+(this.id == "thread" ? "threadall" : "thread")).checked = false;
+ }
+}
+
window.addEventListener("load", function() {
i18n();
@@ -59,6 +66,7 @@
}
});
+ ["thread", "threadall"].forEach(el => document.querySelector("#"+el).addEventListener("change", thread));
document.querySelector("#save").addEventListener("click", save);
});
});
diff --git a/thread_inject.js b/thread_inject.js
index bfaa0fa..e756640 100644
--- a/thread_inject.js
+++ b/thread_inject.js
@@ -22,5 +22,10 @@
intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
intersectionObserver.observe(button);
}
+ var allbutton = document.querySelector(".thread-all-replies__load-all-button");
+ if (items.threadall && button !== null) {
+ intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+ intersectionObserver.observe(allbutton);
+ }
}
});