Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #124 #125

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
dist/
archive/
*.zip
Expand Down
175 changes: 121 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lint:styl": "stylint src/features/*.styl",
"lint-fix": "run-p --silent 'lint:* -- --fix'",
"clean": "rimraf dist",
"build": "webpack --mode=production",
"build": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode=production",
"watch": "webpack --mode=development --watch",
"watch:firefox": "web-ext run --source-dir=dist",
"version": "dot-json dist/manifest.json version $VER",
Expand Down Expand Up @@ -36,6 +36,7 @@
"rimraf": "^2.6.3",
"size-plugin": "^1.2.0",
"stylint": "^2.0.0",
"stylus": "^0.59.0",
"terser-webpack-plugin": "^1.3.0",
"web-ext": "^3.1.1",
"web-ext-submit": "^3.1.1",
Expand Down
6 changes: 2 additions & 4 deletions src/features/hide-read-stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { createOptionsBar, getGroupedStories } from "../libs/dom-utils";
import { paths } from "../libs/paths";

function requestVisitedStories(options) {
const itemList = document.querySelector("table.itemlist");
const stories = getGroupedStories(itemList);
const stories = getGroupedStories();
const links = {};

for (const story of stories) {
Expand All @@ -23,8 +22,7 @@ function requestVisitedStories(options) {
}

function hideStories(idList, hide) {
const itemList = document.querySelector("table.itemlist");
const stories = getGroupedStories(itemList);
const stories = getGroupedStories();

for (const id of idList) {
const story = stories.find((obj) => obj.id === id);
Expand Down
6 changes: 3 additions & 3 deletions src/features/show-similar-submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function init(metadata) {
const discussionRow = document.createElement("tr");
discussionRow.innerHTML = `
<td class='__rhn__discussions-row'>
<p>Discussions on similar submissions:</p>
<p>\*Discussions on similar submissions:\*</p>
<ol></ol>
</td>
`;
Expand All @@ -83,9 +83,9 @@ async function init(metadata) {

for (const result of results) {
dicussionRowList.innerHTML += `
<li><a href="${result.link}">${result.title}</a> (${result.date} &mdash; ${
<li>\*<a href="${result.link}">${result.title}</a>\* ${result.link} (${result.date} &mdash; ${
result.points
} points, ${result.comments} comments)</li>
} points, ${result.comments} comments)<br /><br /></li>
`;
}

Expand Down
4 changes: 2 additions & 2 deletions src/features/sort-stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function updateStoriesHtml(stories) {

function sort() {
const method = document.querySelector("#sort-stories-input").value;
const stories = getGroupedStories(document.querySelector("table.itemlist"));
const stories = getGroupedStories();

switch (method) {
case "time": {
Expand Down Expand Up @@ -90,7 +90,7 @@ function init(metadata) {

sortSelect.addEventListener("change", sort);
reverseButton.addEventListener("click", () => {
const stories = getGroupedStories(document.querySelector("table.itemlist"));
const stories = getGroupedStories();
updateStoriesHtml(stories.reverse());
});

Expand Down
16 changes: 14 additions & 2 deletions src/libs/dom-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,20 @@ export function getTopLevelComments() {
return topLevelComments;
}

export function getGroupedStories(itemlist) {
const rows = [...itemlist.querySelectorAll(":scope > tbody > tr")];
export function getGroupedStories() {
const itemList = document.querySelector("#pagespace + div + tr table");
return getGroupedStoriesItemList(itemList);
}

export function getGroupedStoriesItemList(itemlist) {
if (!itemlist) {
return [];
}
const results = itemlist.querySelectorAll(":scope > tbody > tr");
if (!results) {
return [];
}
const rows = results;
while (!rows[0].matches(".athing")) {
rows.shift();
}
Expand Down
Loading