Fixes #4
diff --git a/console_inject.js b/console_inject.js
index d3dc258..aab2eb6 100644
--- a/console_inject.js
+++ b/console_inject.js
@@ -4,13 +4,27 @@
mutationList.forEach((mutation) => {
if (mutation.type == "childList") {
mutation.addedNodes.forEach(function (node) {
- if (options.list && (typeof node.classList !== "undefined") && node.classList.contains("view-more-button-container")) {
- intersectionObserver.observe(node.querySelector(".view-more-button"));
- }
+ if (typeof node.classList !== "undefined") {
+ if (options.list && node.classList.contains("view-more-button-container")) {
+ intersectionObserver.observe(node.querySelector(".view-more-button"));
+ }
- if (options.thread && (typeof node.classList !== "undefined") && node.classList.contains("load-more-bar")) {
- intersectionObserver.observe(node.querySelector(".load-more-button"));
- }
+ if (options.thread && node.classList.contains("load-more-bar")) {
+ intersectionObserver.observe(node.querySelector(".load-more-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) {
+ var name = encodeURIComponent(nameElement.innerText);
+ var link = document.createElement("a");
+ link.setAttribute("href", "https://support.google.com/s/community/search/query%3D%2528creator%253A%2522"+name+"%2522%2B%257C%2Breplier%253A%2522"+name+"%2522%2529%2B-forum%253A0");
+ link.innerText = "Previous posts";
+ node.querySelector(".main-card").appendChild(document.createElement("br"));
+ node.querySelector(".main-card").appendChild(link);
+ }
+ }
+ }
});
}
});
diff --git a/manifest.json b/manifest.json
index af381a9..723370b 100644
--- a/manifest.json
+++ b/manifest.json
@@ -20,6 +20,10 @@
"matches": ["https://support.google.com/*/thread/*"],
"js": ["thread_inject.js"],
"run_at": "document_end"
+ },
+ {
+ "matches": ["https://support.google.com/*/profile/*"],
+ "js": ["profile_inject.js"]
}
],
"permissions": [
diff --git a/profile_inject.js b/profile_inject.js
new file mode 100644
index 0000000..2743672
--- /dev/null
+++ b/profile_inject.js
@@ -0,0 +1,10 @@
+chrome.storage.sync.get(null, function(items) {
+ if (items.history && document.querySelector(".user-profile__user-links") === null) {
+ var nameElement = document.querySelector(".user-profile__user-name");
+ if (nameElement !== null) {
+ var name = encodeURIComponent(nameElement.innerText);
+ var link = document.location.pathname.split("/profile")[0]+"/threads?hl=en&thread_filter=(creator:%22"+name+"%22+%7C+replier:%22"+name+"%22)";
+ document.querySelector(".user-profile__user-details-container").insertAdjacentHTML('beforeend', '<div class="user-profile__user-links"><div class="user-profile__user-link-title">Links</div><ul><li class="user-profile__user-link"><a href="'+link+'" data-stats-id="my-posts-link">Previous posts</a></li></ul></div>');
+ }
+ }
+});