From a4a665496f75bcd248a8a4885361228038198d2d Mon Sep 17 00:00:00 2001 From: faraplay Date: Sun, 2 Jul 2023 20:27:02 +0100 Subject: [PATCH 1/5] setup tasks in vscode --- .vscode/tasks.json | 24 ++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..c25dfef --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,24 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "wp-build", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "label": "npm: wp-build", + "detail": "webpack" + }, + { + "type": "npm", + "script": "install", + "group": "none", + "problemMatcher": [], + "label": "npm: install", + "detail": "install dependencies from package" + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index d329075..fdb583f 100644 --- a/package.json +++ b/package.json @@ -58,4 +58,4 @@ "webpack-cli": "^5.1.1" }, "packageManager": "yarn@3.6.0" -} \ No newline at end of file +} From db1a1e877e5be8bc009d041fda6cc370772b58c9 Mon Sep 17 00:00:00 2001 From: faraplay Date: Sun, 2 Jul 2023 20:49:13 +0100 Subject: [PATCH 2/5] fix subreddit sidebar exception when there is no sidebar --- js/sidebars.js | 8 +++++--- js/subreddit_sidebar.js | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/sidebars.js b/js/sidebars.js index 62389a1..dbb9f69 100644 --- a/js/sidebars.js +++ b/js/sidebars.js @@ -4,10 +4,12 @@ function setupSidebars() { const [toggleSub, subSide] = setupSubredditSidebar(); const [toggleUser, userSide] = setupUserSidebar(); document.addEventListener("toggleUser", toggleUser); - document.addEventListener("toggleSub", toggleSub); + if (toggleSub) { + document.addEventListener("toggleSub", toggleSub); + } document.addEventListener("swiped-right", function (e) { // sidebar.classList.remove("active"); - if (subSide.classList.contains("active")) { + if (subSide && subSide.classList.contains("active")) { toggleSub(); return; } @@ -21,7 +23,7 @@ function setupSidebars() { toggleUser(); return; } - if (!subSide.classList.contains("active")) { + if (subSide && !subSide.classList.contains("active")) { toggleSub(); } }); diff --git a/js/subreddit_sidebar.js b/js/subreddit_sidebar.js index 42d36a0..6487a61 100644 --- a/js/subreddit_sidebar.js +++ b/js/subreddit_sidebar.js @@ -4,6 +4,9 @@ export default function setupSidebar() { const sidebar = document.createElement("div"); const sidebarToggle = document.createElement("div"); const actualSidebar = document.querySelector(".side"); + if (!actualSidebar) { + return [null, null]; + } sidebarToggle.id = "sidebar-toggle"; sidebar.id = "custom-sidebar"; sidebar.appendChild(sidebarToggle); From 7d04f7cf6d5df72c3599f2fed43d86bd2400ea59 Mon Sep 17 00:00:00 2001 From: faraplay Date: Sun, 2 Jul 2023 21:24:57 +0100 Subject: [PATCH 3/5] change layout of preferences page --- css/customUi.css | 5 +++++ js/cs.js | 1 + js/preferences.js | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 js/preferences.js diff --git a/css/customUi.css b/css/customUi.css index f6a49a9..417fe75 100644 --- a/css/customUi.css +++ b/css/customUi.css @@ -38,3 +38,8 @@ form.usertext { #header { display: none; } + +div.pref-row { + border-top: 1px dotted gray; + padding-bottom: 10px; +} diff --git a/js/cs.js b/js/cs.js index 0c8cd7f..095059a 100644 --- a/js/cs.js +++ b/js/cs.js @@ -3,4 +3,5 @@ import "./general.js"; import "./header.js"; import "./sidebars.js"; import "./posts"; +import "./preferences.js"; console.log("Content script loaded."); diff --git a/js/preferences.js b/js/preferences.js new file mode 100644 index 0000000..d8d4abf --- /dev/null +++ b/js/preferences.js @@ -0,0 +1,26 @@ +export function formatPrefTable() { + const table = document.querySelector("table.preftable"); + if (!table) { + return; + } + console.log("Test message from pref 1"); + const tableParent = table.parentNode; + const prefDiv = document.createElement("div"); + tableParent.appendChild(prefDiv); + tableParent.removeChild(table); + const tbody = table.firstChild; + for (const row of tbody.childNodes) { + const newRow = document.createElement("div"); + newRow.setAttribute("class", "pref-row"); + prefDiv.appendChild(newRow); + + const header = document.createElement("h1"); + header.innerText = row.firstChild.innerText; + newRow.appendChild(header); + + const prefright = row.lastChild; + newRow.appendChild(prefright); + } +} + +formatPrefTable(); \ No newline at end of file From 767ec95fad740eda6c807d8d1cc3c21edac3f314 Mon Sep 17 00:00:00 2001 From: faraplay Date: Sun, 2 Jul 2023 22:15:18 +0100 Subject: [PATCH 4/5] import preferences.js in user.js --- js/preferences.js | 1 - js/user.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/js/preferences.js b/js/preferences.js index d8d4abf..cae4a8c 100644 --- a/js/preferences.js +++ b/js/preferences.js @@ -3,7 +3,6 @@ export function formatPrefTable() { if (!table) { return; } - console.log("Test message from pref 1"); const tableParent = table.parentNode; const prefDiv = document.createElement("div"); tableParent.appendChild(prefDiv); diff --git a/js/user.js b/js/user.js index cdae7f1..3da5fdc 100644 --- a/js/user.js +++ b/js/user.js @@ -3,5 +3,6 @@ import "./general.js"; import "./header.js"; import "./sidebars.js"; import "./posts"; +import "./preferences.js"; console.log("oldlander user.js loaded"); From 2aadb614a193913593aa27a884bb875dd9332925 Mon Sep 17 00:00:00 2001 From: faraplay Date: Sun, 2 Jul 2023 22:24:45 +0100 Subject: [PATCH 5/5] use color scheme for div border-top color --- css/customUi.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/customUi.css b/css/customUi.css index 417fe75..302b85d 100644 --- a/css/customUi.css +++ b/css/customUi.css @@ -40,6 +40,6 @@ form.usertext { } div.pref-row { - border-top: 1px dotted gray; + border-top: 1px solid var(--md-sys-color-outline-variant); padding-bottom: 10px; }