From 6965b8589d9433feab4d2781bd0388e7dbd8bb4d Mon Sep 17 00:00:00 2001 From: ilovecherries Date: Thu, 21 Jul 2022 14:05:15 -0400 Subject: [PATCH 1/4] link to page in sidebar --- src/sidebar.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sidebar.js b/src/sidebar.js index d5e74d9..f37d0f9 100644 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -233,8 +233,9 @@ const Sidebar = NAMESPACE({ link.href = "#user/"+comment.createUserId link.firstChild.src = Draw.avatar_url(author) link.lastChild.textContent = name - - d.append(comment.text.replace(/\n/g, " ")) + let content = d.lastChild + content.href = "#page/"+comment.contentId + content.append(comment.text.replace(/\n/g, " ")) return d }.bind(𐀶` @@ -243,6 +244,8 @@ const Sidebar = NAMESPACE({ : + + `), From 530301e89c9b5b61dd4522851e361d861d504fca Mon Sep 17 00:00:00 2001 From: ilovecherries Date: Thu, 21 Jul 2022 16:51:55 -0400 Subject: [PATCH 2/4] added setting for sidebar linkify --- src/sidebar.js | 27 +++++++++++++++++++++++---- src/style.css | 13 +++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/sidebar.js b/src/sidebar.js index f37d0f9..2dc7ff9 100644 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -234,8 +234,9 @@ const Sidebar = NAMESPACE({ link.firstChild.src = Draw.avatar_url(author) link.lastChild.textContent = name let content = d.lastChild - content.href = "#page/"+comment.contentId - content.append(comment.text.replace(/\n/g, " ")) + content.firstChild.href = "#page/"+comment.contentId + content.childNodes.forEach(n => + n.append(comment.text.replace(/\n/g, " "))) return d }.bind(𐀶` @@ -244,8 +245,11 @@ const Sidebar = NAMESPACE({ : - - + + + + + `), @@ -282,3 +286,18 @@ Object.defineProperty(window, 'log', { }) do_when_ready(x=>Sidebar.onload()) + +Settings.add({ + name: 'linkify_sidebar_messages', label: 'Linkify Sidebar Messages', + type: 'select', + options: ['no', 'yes'], + update(value) { + do_when_ready(() => { + if (value === 'yes') { + $sidebarBottom.setAttribute("linkify", "") + } else { + $sidebarBottom.removeAttribute("linkify") + } + }) + }, +}) \ No newline at end of file diff --git a/src/style.css b/src/style.css index c811379..40513e7 100644 --- a/src/style.css +++ b/src/style.css @@ -902,6 +902,19 @@ activity-users { overflow-y: scroll; width: 100%; } +#\$sidebarBottom .sidebar-message-content > a { + display: none; + color: var(--T-color); +} +#\$sidebarBottom[linkify] .sidebar-message-content > a { + display: inline; +} +#\$sidebarBottom .sidebar-message-content > span { + display: inline; +} +#\$sidebarBottom[linkify] .sidebar-message-content > span { + display: none; +} /* contain */ #\$sidebarBottom, From eb92054eebb176f2b0f90e11e4f3d71b79f57a9d Mon Sep 17 00:00:00 2001 From: Cherry Date: Thu, 21 Jul 2022 23:46:43 -0400 Subject: [PATCH 3/4] changed to manipulate href attribute instead of swapping properties --- src/sidebar.js | 31 ++++++++++++++++++++----------- src/style.css | 12 +----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/sidebar.js b/src/sidebar.js index 2dc7ff9..5e0434e 100644 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -5,6 +5,7 @@ const Sidebar = NAMESPACE({ tabs: null, $my_avatar: null, userlist: new StatusDisplay(0, null), + linkify_messages: false, normal_open: false, fullscreen_open: false, @@ -234,9 +235,12 @@ const Sidebar = NAMESPACE({ link.firstChild.src = Draw.avatar_url(author) link.lastChild.textContent = name let content = d.lastChild - content.firstChild.href = "#page/"+comment.contentId - content.childNodes.forEach(n => - n.append(comment.text.replace(/\n/g, " "))) + content.setAttribute("page", comment.contentId) + if (Sidebar.linkify_messages) { + content.href = "#page/"+comment.contentId + } + content.setAttribute('aria-disabled', String(!Sidebar.linkify_messages)) + content.append(comment.text.replace(/\n/g, " ")) return d }.bind(𐀶` @@ -245,11 +249,8 @@ const Sidebar = NAMESPACE({ : - - - - - + + `), @@ -293,10 +294,18 @@ Settings.add({ options: ['no', 'yes'], update(value) { do_when_ready(() => { - if (value === 'yes') { - $sidebarBottom.setAttribute("linkify", "") + Sidebar.linkify_messages = (value === 'yes') + const contents = document.querySelectorAll('#\\$sidebarBottom .sidebar-message-content') + if (Sidebar.linkify_messages) { + contents.forEach(c => { + c.setAttribute('href', `#page/${c.getAttribute("page")}`) + c.setAttribute('aria-disabled', "true") + }) } else { - $sidebarBottom.removeAttribute("linkify") + contents.forEach(c => { + c.removeAttribute('href') + c.setAttribute('aria-disabled', "false") + }) } }) }, diff --git a/src/style.css b/src/style.css index 40513e7..56bca05 100644 --- a/src/style.css +++ b/src/style.css @@ -902,19 +902,9 @@ activity-users { overflow-y: scroll; width: 100%; } -#\$sidebarBottom .sidebar-message-content > a { - display: none; +#\$sidebarBottom .sidebar-message-content { color: var(--T-color); } -#\$sidebarBottom[linkify] .sidebar-message-content > a { - display: inline; -} -#\$sidebarBottom .sidebar-message-content > span { - display: inline; -} -#\$sidebarBottom[linkify] .sidebar-message-content > span { - display: none; -} /* contain */ #\$sidebarBottom, From 12f61cb537ded51e2f034998d5d1f17ca7f9ce8b Mon Sep 17 00:00:00 2001 From: ilovecherries Date: Sat, 23 Jul 2022 19:12:54 -0400 Subject: [PATCH 4/4] what the fuck that's the wrong order --- src/sidebar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sidebar.js b/src/sidebar.js index 5e0434e..597837b 100644 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -299,12 +299,12 @@ Settings.add({ if (Sidebar.linkify_messages) { contents.forEach(c => { c.setAttribute('href', `#page/${c.getAttribute("page")}`) - c.setAttribute('aria-disabled', "true") + c.setAttribute('aria-disabled', "false") }) } else { contents.forEach(c => { c.removeAttribute('href') - c.setAttribute('aria-disabled', "false") + c.setAttribute('aria-disabled', "true") }) } })