From 93d2333528aaa470f3f80a9f90c5efbacfcf178c Mon Sep 17 00:00:00 2001 From: Public Profile Date: Fri, 2 Dec 2022 09:34:49 -0800 Subject: [PATCH 01/10] ignore my ide --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e9a13ba..9910284 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ dist/ archive/ *.zip From 3ddb8c8ba61efe411c193ecf406cdcbb5450fe94 Mon Sep 17 00:00:00 2001 From: Public Profile Date: Fri, 2 Dec 2022 09:35:33 -0800 Subject: [PATCH 02/10] add build dependency on stylus --- package-lock.json | 175 ++++++++++++++++++++++++++++++++-------------- package.json | 1 + 2 files changed, 122 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index f1761b9..53d02b3 100755 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,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", @@ -31,6 +32,12 @@ "xo": "^0.24.0" } }, + "node_modules/@adobe/css-tools": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.0.1.tgz", + "integrity": "sha512-+u76oB43nOHrF4DDWRLWDCtci7f3QJoEBigemIdIeTi1ODqjx6Tad9NCVnPRwewWlKkVab5PlK8DCtPTyX7S8g==", + "dev": true + }, "node_modules/@babel/code-frame": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", @@ -1714,23 +1721,6 @@ "y18n": "^4.0.0" } }, - "node_modules/cacache/node_modules/glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - } - }, "node_modules/cacache/node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -3789,13 +3779,20 @@ "dev": true }, "node_modules/debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/decamelize": { @@ -6716,20 +6713,23 @@ } }, "node_modules/glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, "engines": { "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/glob-parent": { @@ -6760,6 +6760,18 @@ "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", "dev": true }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/global-dirs": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", @@ -9069,9 +9081,9 @@ } }, "node_modules/ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "node_modules/multimatch": { @@ -13461,6 +13473,37 @@ "lodash.assign": "^4.0.6" } }, + "node_modules/stylus": { + "version": "0.59.0", + "resolved": "https://registry.npmjs.org/stylus/-/stylus-0.59.0.tgz", + "integrity": "sha512-lQ9w/XIOH5ZHVNuNbWW8D822r+/wBSO/d6XvtyHLF7LW4KaCIDeVbvn5DF8fGCJAUCwVhVi/h6J0NUcnylUEjg==", + "dev": true, + "dependencies": { + "@adobe/css-tools": "^4.0.1", + "debug": "^4.3.2", + "glob": "^7.1.6", + "sax": "~1.2.4", + "source-map": "^0.7.3" + }, + "bin": { + "stylus": "bin/stylus" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://opencollective.com/stylus" + } + }, + "node_modules/stylus/node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", @@ -15874,6 +15917,12 @@ } }, "dependencies": { + "@adobe/css-tools": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.0.1.tgz", + "integrity": "sha512-+u76oB43nOHrF4DDWRLWDCtci7f3QJoEBigemIdIeTi1ODqjx6Tad9NCVnPRwewWlKkVab5PlK8DCtPTyX7S8g==", + "dev": true + }, "@babel/code-frame": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", @@ -17351,20 +17400,6 @@ "y18n": "^4.0.0" }, "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, "lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -19029,12 +19064,12 @@ "dev": true }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } }, "decamelize": { @@ -21434,17 +21469,28 @@ } }, "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "glob-parent": { @@ -23396,9 +23442,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "multimatch": { @@ -27078,6 +27124,27 @@ } } }, + "stylus": { + "version": "0.59.0", + "resolved": "https://registry.npmjs.org/stylus/-/stylus-0.59.0.tgz", + "integrity": "sha512-lQ9w/XIOH5ZHVNuNbWW8D822r+/wBSO/d6XvtyHLF7LW4KaCIDeVbvn5DF8fGCJAUCwVhVi/h6J0NUcnylUEjg==", + "dev": true, + "requires": { + "@adobe/css-tools": "^4.0.1", + "debug": "^4.3.2", + "glob": "^7.1.6", + "sax": "~1.2.4", + "source-map": "^0.7.3" + }, + "dependencies": { + "source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true + } + } + }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", diff --git a/package.json b/package.json index a15cbd8..fe10124 100755 --- a/package.json +++ b/package.json @@ -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", From 2f561007e092ebf95e4654ab1c6af43703768f8a Mon Sep 17 00:00:00 2001 From: Public Profile Date: Fri, 2 Dec 2022 09:36:25 -0800 Subject: [PATCH 03/10] fix: issue with selecting main table #124 --- src/features/hide-read-stories.js | 6 ++---- src/features/sort-stories.js | 4 ++-- src/libs/dom-utils.js | 7 ++++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/features/hide-read-stories.js b/src/features/hide-read-stories.js index c3f3d4c..22c185c 100755 --- a/src/features/hide-read-stories.js +++ b/src/features/hide-read-stories.js @@ -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) { @@ -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); diff --git a/src/features/sort-stories.js b/src/features/sort-stories.js index 1fa364e..070a51f 100755 --- a/src/features/sort-stories.js +++ b/src/features/sort-stories.js @@ -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": { @@ -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()); }); diff --git a/src/libs/dom-utils.js b/src/libs/dom-utils.js index 35d903a..616d0e1 100755 --- a/src/libs/dom-utils.js +++ b/src/libs/dom-utils.js @@ -57,7 +57,12 @@ export function getTopLevelComments() { return topLevelComments; } -export function getGroupedStories(itemlist) { +export function getGroupedStories() { + const itemList = document.querySelector("#hnmain tr:nth-child(4) table"); + return getGroupedStoriesItemList(itemList); +} + +export function getGroupedStoriesItemList(itemlist) { const rows = [...itemlist.querySelectorAll(":scope > tbody > tr")]; while (!rows[0].matches(".athing")) { rows.shift(); From 260d0425f4feb1eeee92d45b9f35106958218bb4 Mon Sep 17 00:00:00 2001 From: Public Profile Date: Sat, 3 Dec 2022 09:46:52 -0800 Subject: [PATCH 04/10] check for null --- src/libs/utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/utils.js b/src/libs/utils.js index b22ff00..3b43224 100755 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -87,6 +87,7 @@ export function getUserData(path) { let actualTopBar = topBarElements[0]; let topcolor = "#ff6600"; if ( + actualTopBar && actualTopBar.children.length === 1 && actualTopBar.children[0].tagName === "IMG" ) { From 3e63505536d8c2d5c4d5ab8d9d142d4e0631722e Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 5 Apr 2023 14:38:32 -0700 Subject: [PATCH 05/10] remove brave error --- src/manifest.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index 9cd714f..18c60a8 100755 --- a/src/manifest.json +++ b/src/manifest.json @@ -39,10 +39,5 @@ "js": ["browser-polyfill.min.js", "refined-hacker-news.js"] } ], - "web_accessible_resources": ["loader.gif"], - "applications": { - "gecko": { - "id": "refinedhackernews@mihir.ch" - } - } + "web_accessible_resources": ["loader.gif"] } From 07860c35e56b976f6302d9026387ea5ded0c63a7 Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 5 Apr 2023 14:39:01 -0700 Subject: [PATCH 06/10] deal with nulls --- src/libs/dom-utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/dom-utils.js b/src/libs/dom-utils.js index 616d0e1..0dd0b74 100755 --- a/src/libs/dom-utils.js +++ b/src/libs/dom-utils.js @@ -63,7 +63,14 @@ export function getGroupedStories() { } export function getGroupedStoriesItemList(itemlist) { - const rows = [...itemlist.querySelectorAll(":scope > tbody > tr")]; + if (!itemlist) { + return []; + } + const results = itemlist.querySelectorAll(":scope > tbody > tr"); + if (!results) { + return []; + } + const rows = results; while (!rows[0].matches(".athing")) { rows.shift(); } From 641cc018cbd20a6190cdd51705bf780c60da4daf Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 5 Apr 2023 14:49:20 -0700 Subject: [PATCH 07/10] better selector than using numbers --- src/libs/dom-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/dom-utils.js b/src/libs/dom-utils.js index 0dd0b74..3efde0b 100755 --- a/src/libs/dom-utils.js +++ b/src/libs/dom-utils.js @@ -58,7 +58,7 @@ export function getTopLevelComments() { } export function getGroupedStories() { - const itemList = document.querySelector("#hnmain tr:nth-child(4) table"); + const itemList = document.querySelector("#pagespace + div + tr table"); return getGroupedStoriesItemList(itemList); } From bbe84ba7a3e1fe41a262c730ddd790fa7019e12f Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 4 Oct 2023 11:13:38 -0700 Subject: [PATCH 08/10] latest node requires this. why does JS software always rot over time? --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe10124..56821ed 100755 --- a/package.json +++ b/package.json @@ -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", From 0df30e2da999bf38cf0327fa9427f789e60e7e29 Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 4 Oct 2023 11:14:02 -0700 Subject: [PATCH 09/10] append the link to make the output more useful for copy/paste. --- src/features/show-similar-submissions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/show-similar-submissions.js b/src/features/show-similar-submissions.js index 45a4ad8..f2f4683 100755 --- a/src/features/show-similar-submissions.js +++ b/src/features/show-similar-submissions.js @@ -83,7 +83,7 @@ async function init(metadata) { for (const result of results) { dicussionRowList.innerHTML += ` -
  • ${result.title} (${result.date} — ${ +
  • ${result.title} ${result.link} (${result.date} — ${ result.points } points, ${result.comments} comments)
  • `; From f8e6efb253ca76e778cee1fc9b33963bafc24858 Mon Sep 17 00:00:00 2001 From: Public Profile Date: Wed, 4 Oct 2023 11:28:50 -0700 Subject: [PATCH 10/10] refined for easy copy/paste --- src/features/show-similar-submissions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/features/show-similar-submissions.js b/src/features/show-similar-submissions.js index f2f4683..593a329 100755 --- a/src/features/show-similar-submissions.js +++ b/src/features/show-similar-submissions.js @@ -74,7 +74,7 @@ async function init(metadata) { const discussionRow = document.createElement("tr"); discussionRow.innerHTML = ` -

    Discussions on similar submissions:

    +

    \*Discussions on similar submissions:\*

      `; @@ -83,9 +83,9 @@ async function init(metadata) { for (const result of results) { dicussionRowList.innerHTML += ` -
    1. ${result.title} ${result.link} (${result.date} — ${ +
    2. \*${result.title}\* ${result.link} (${result.date} — ${ result.points - } points, ${result.comments} comments)
    3. + } points, ${result.comments} comments)

      `; }