Skip to content

Commit 7a4a989

Browse files
authored
Merge pull request #47 from LaserMoai/master
Support navigation tables
2 parents 7fdf625 + ce7ea6c commit 7a4a989

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

components/api.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,20 @@ export class Trope {
8383
}
8484

8585
private extractTitle(document: Document) {
86-
const titleElement = document.querySelector(".entry-title a");
87-
if (titleElement?.textContent) {
88-
return titleElement.textContent.trim();
86+
const titleElement = document.querySelector(
87+
".wrap-entry-breadcrumb strong"
88+
);
89+
const text = titleElement
90+
? Array.prototype.filter
91+
.call(
92+
titleElement?.childNodes,
93+
(child) => child.nodeType === Node.TEXT_NODE
94+
)
95+
.map((child) => child.textContent)
96+
.join("")
97+
: null;
98+
if (text) {
99+
return text.trim();
89100
}
90101
throw new LaconicError("NO_TITLE");
91102
}

entrypoints/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { defineContentScript } from "wxt/sandbox";
88

99
const INITIAL_CONTENT = "Loading...";
1010
const HOVER_SELECTOR =
11-
".twikilink, .subpage-link[title='The Laconic page']:not(.curr-subpage)";
11+
".twikilink, .subpage-link[title='The Laconic page']:not(.curr-subpage), .section-links a";
1212

1313
export default defineContentScript({
1414
matches: ["*://tvtropes.org/*"],

0 commit comments

Comments
 (0)