Fix: don't redirect TW new thread page to the CC
As pointed out at pekb/thread/60972469?msgid=6546485, the new thread
page is being incorrectly redirected to the CC. This commit fixes this.
This bug is a regression introduced by commit adf9086.
Change-Id: I9d858fc4e6822662bc3aca6d1925b7c6bf42dab7
diff --git a/src/thread_inject.js b/src/thread_inject.js
index 1d65dc6..c3b484e 100644
--- a/src/thread_inject.js
+++ b/src/thread_inject.js
@@ -13,18 +13,29 @@
}
chrome.storage.sync.get(null, function(items) {
+ var path = document.location.pathname.split("/");
+ if (path[path.length - 1] == "new" ||
+ (path.length > 1 && path[path.length - 1] == "" &&
+ path[path.length - 2] == "new")) {
+ return;
+ }
+
var redirectLink = document.querySelector(".community-console");
if (items.redirect && redirectLink !== null) {
window.location = redirectLink.href;
} else {
- var button = document.querySelector(".thread-all-replies__load-more-button");
+ var button =
+ document.querySelector(".thread-all-replies__load-more-button");
if (items.thread && button !== null) {
- intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+ intersectionObserver =
+ new IntersectionObserver(intersectionCallback, intersectionOptions);
intersectionObserver.observe(button);
}
- var allbutton = document.querySelector(".thread-all-replies__load-all-button");
+ var allbutton =
+ document.querySelector(".thread-all-replies__load-all-button");
if (items.threadall && button !== null) {
- intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+ intersectionObserver =
+ new IntersectionObserver(intersectionCallback, intersectionOptions);
intersectionObserver.observe(allbutton);
}
}