Fixes #3
diff --git a/manifest.json b/manifest.json
index 10c4315..af381a9 100644
--- a/manifest.json
+++ b/manifest.json
@@ -18,7 +18,8 @@
},
{
"matches": ["https://support.google.com/*/thread/*"],
- "js": ["thread_inject.js"]
+ "js": ["thread_inject.js"],
+ "run_at": "document_end"
}
],
"permissions": [
diff --git a/options.html b/options.html
index 655b474..bacfa83 100644
--- a/options.html
+++ b/options.html
@@ -12,7 +12,7 @@
<h4>Additional enhancements</h4>
<p>
<input type="checkbox" id="fixedtoolbar"><label for="fixedtoolbar"> Fix the toolbar in thread lists in the Community Console.</label><br>
- <input type="checkbox" id="redirect"><label for="redirect"> Redirect all threads opened in TW to the Community Console. <span style="color: gray;">(doesn't work, in development)</span></label><br>
+ <input type="checkbox" id="redirect"><label for="redirect"> Redirect all threads opened in TW to the Community Console.<span style="color: gray;">(experimental)</span></label><br>
<input type="checkbox" id="history"><label for="history"> Show a "previous posts" link in user profiles. <span style="color: gray;">(doesn't work, in development)</span></label>
</p>
<p style="text-align: center;"><button id="save">Save</button></p>
diff --git a/thread_inject.js b/thread_inject.js
index 0cbc254..bfaa0fa 100644
--- a/thread_inject.js
+++ b/thread_inject.js
@@ -13,9 +13,14 @@
}
chrome.storage.sync.get(null, function(items) {
- var button = document.querySelector(".thread-all-replies__load-more-button");
- if (items.thread && button !== null) {
- intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
- intersectionObserver.observe(button);
+ var redirectLink = document.querySelector(".thread-question__open-in-community-console-button");
+ if (items.redirect && redirectLink !== null) {
+ window.location = redirectLink.href;
+ } else {
+ var button = document.querySelector(".thread-all-replies__load-more-button");
+ if (items.thread && button !== null) {
+ intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+ intersectionObserver.observe(button);
+ }
}
});