Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dteviot committed Aug 10, 2021
1 parent 9f0280b commit 55f17e4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions plugin/js/parsers/GamefaqsGamespotParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use strict";

parserFactory.register("gamefaqs.gamespot.com", () => new GamefaqsGamespotParser());

class GamefaqsGamespotParser extends Parser{
constructor() {
super();
}

async getChapterUrls(dom) {
let toc = dom.querySelector(".ftoc");
if (toc !== null) {
return this.linksToChapters(dom.baseURI, toc)
}
toc = dom.querySelector("div.main_content");
if (toc !== null) {
util.removeChildElementsMatchingCss(toc, "nav.content_nav_wrap");
return this.linksToChapters(dom.baseURI, toc)
}
return [];
}

linksToChapters(base, toc){
if (!base.endsWith("/")) {
base += "/";
}
let baseUrl = new URL(base);
return [...toc.querySelectorAll("a")].map(link => ({
sourceUrl: new URL(link.getAttribute("href"), baseUrl).toString(),
title: link.innerText.trim(),
}));
}

findContent(dom) {
return dom.querySelector("#faqwrap");
}

extractTitleImpl(dom) {
return dom.querySelector("h3.platform-title");
}

extractAuthor(dom) {
let authorLabel = dom.querySelector("a.contrib1");
return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent;
}

removeUnwantedElementsFromContentElement(element) {
util.removeChildElementsMatchingCss(element, ".ftoc");
super.removeUnwantedElementsFromContentElement(element);
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ <h3>Instructions</h3>
<script src="js/parsers/FlyingLinesParser.js"></script>
<script src="js/parsers/FoxtellerParser.js"></script>
<script src="js/parsers/FreeWebNovelParser.js"></script>
<script src="js/parsers/GamefaqsGamespotParser.js"></script>
<script src="js/parsers/GoblinsguideParser.js"></script>
<script src="js/parsers/GraverobbertlParser.js"></script>
<script src="js/parsers/GravityTalesParser.js"></script>
Expand Down

0 comments on commit 55f17e4

Please sign in to comment.