From f6933e9e504898764fc18623a51d7a766498d5ab Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 16 Jun 2023 23:05:30 +1200 Subject: [PATCH 1/8] expand all Warframe ability collapsibles --- lib/tree-updater.rkt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tree-updater.rkt b/lib/tree-updater.rkt index 098af3d..9e30f32 100644 --- a/lib/tree-updater.rkt +++ b/lib/tree-updater.rkt @@ -110,6 +110,11 @@ #;(curry attribute-maybe-update 'class (λ (class) (string-join (classlist-updater (string-split class " ")) " "))) (curry attribute-maybe-update 'class class-updater) + ; yet more uncollapsing - sample: warframe/wiki/Amp_(Ability) + (curry u + (λ (v) (and (dict-has-key? v 'id) + (string-prefix? (car (dict-ref v 'id)) "mw-customcollapsible"))) + (λ (v) (dict-set v 'style "display:block"))) ; change links to stay on the same wiki (curry attribute-maybe-update 'href (λ (href) @@ -245,6 +250,9 @@ ; remove gamespot reviews/ads [(has-class? "reviews" attributes) return-no-element] + ; remove customcollapsible customtoggle buttons - sample: warframe/wiki/Amp_(Ability) + [(and (dict-has-key? attributes 'class) (regexp-match? #rx"^mw-customtoggle-[^ ]* button-c$" (car (dict-ref attributes 'class)))) + return-no-element] [#t (list element-type ;; attributes From 4336e4ab4323446e2e1e29e55f684bca3742f674 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 17 Jun 2023 00:09:59 +1200 Subject: [PATCH 2/8] fix javascript audio buttons on hearthstone wiki --- lib/tree-updater.rkt | 4 ++++ static/main.css | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/tree-updater.rkt b/lib/tree-updater.rkt index 9e30f32..109c875 100644 --- a/lib/tree-updater.rkt +++ b/lib/tree-updater.rkt @@ -110,6 +110,10 @@ #;(curry attribute-maybe-update 'class (λ (class) (string-join (classlist-updater (string-split class " ")) " "))) (curry attribute-maybe-update 'class class-updater) + ; audio buttons - sample: hearthstone/wiki/Diablo_(Duels_hero)#Sounds + (curry u + (λ (v) (has-class? "ext-audiobutton" v)) + (λ (v) (dict-set (dict-remove v 'hidden) 'controls '("")))) ; yet more uncollapsing - sample: warframe/wiki/Amp_(Ability) (curry u (λ (v) (and (dict-has-key? v 'id) diff --git a/static/main.css b/static/main.css index 3d3ed5a..9414470 100644 --- a/static/main.css +++ b/static/main.css @@ -210,6 +210,11 @@ figcaption, .lightbox-caption, .thumbcaption { display: block; } +/* javascript audio play buttons, see hearthstone/wiki/Diablo_(Duels_hero) */ +a.ext-audiobutton { + display: none; +} + /* animated slots */ #mw-content-text .animated > :not(.animated-active), #mw-content-text .animated > .animated-subframe > :not(.animated-active) { display: inline-block; From 61d28203420120aa0df009212bae6614b66c2ad8 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 17 Jun 2023 00:16:11 +1200 Subject: [PATCH 3/8] fix some more play buttons on minecraft wiki --- static/main.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/static/main.css b/static/main.css index 9414470..1641886 100644 --- a/static/main.css +++ b/static/main.css @@ -210,10 +210,13 @@ figcaption, .lightbox-caption, .thumbcaption { display: block; } -/* javascript audio play buttons, see hearthstone/wiki/Diablo_(Duels_hero) */ -a.ext-audiobutton { +/* javascript audio play buttons */ +a.ext-audiobutton { /* see hearthstone/wiki/Diablo_(Duels_hero) */ display: none; } +.sound > [style="display:none"] { /* see minecraft/wiki/villager#Sounds */ + display: inline !important; +} /* animated slots */ #mw-content-text .animated > :not(.animated-active), #mw-content-text .animated > .animated-subframe > :not(.animated-active) { From 33591ce0a3019fdf3a4c8634a993854b5d80db5e Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 26 Sep 2023 00:51:55 +1300 Subject: [PATCH 4/8] Add Minecraft to independent wikis --- .gitignore | 2 ++ src/extwiki-data.rkt | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 17b94c5..1faa8f2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ compiled # Personal /config.ini +misc +storage diff --git a/src/extwiki-data.rkt b/src/extwiki-data.rkt index 8878845..ead1696 100644 --- a/src/extwiki-data.rkt +++ b/src/extwiki-data.rkt @@ -61,6 +61,16 @@ ("Browser Extension" . "https://runescape.wiki/w/RuneScape:Finding_the_wikis_with_ease#Extensions")) (λ (props) '())) + 'Minecraft + (extwiki-group^ + "Minecraft" + '(("Post-Move FAQ" . "https://minecraft.wiki/w/Minecraft_Wiki:Moving_from_Fandom") + ("Pre-Move Discussion" . "https://minecraft.fandom.com/wiki/Minecraft_Wiki:Moving_from_Fandom") + ("In the media: PCGamer" . "https://www.pcgamer.com/official-minecraft-wiki-editors-so-furious-at-fandoms-degraded-functionality-and-popups-theyre-overwhelmingly-voting-to-leave-the-site/") + ("In the media: PCGamesN" . "https://www.pcgamesn.com/minecraft/wiki-fandom")) + (λ (props) + '(p "The wiki was founded by Citricsquid on July 16th, 2009 as a way to document information from Minecraft. Since November 15th, 2010, it has been hosted by Curse Media. On December 12th, 2018, it moved to Fandom as it purchased Curse Media. Since September 24, 2023, it forked from Fandom and has been hosted by Weird Gloop."))) + 'empty (extwiki-group^ "Misc" @@ -400,6 +410,15 @@ `((p "“Fandom bought Gamepedia and forced a migration, with their restricted, ad-heavy appearance, and other annoying features that we could not remove, the wiki grew slow and annoying to use, especially for logged out users.") (p "“We decided to move away from Fandom to Wiki.gg, which returns the wiki to how it used to be on gamepedia, without the ads spamming and forced videos.”")))) + (extwiki^ + '("minecraft") 'default + 'Minecraft + "The Minecraft Wiki" + "https://minecraft.wiki/w/Minecraft_Wiki" + "https://minecraft.wiki/images/Wiki.png" + (λ (props) + `())) + ;; fandom wikinames * empty * empty * Name * Home Page (extwiki^ '("aether") 'empty 'empty "Aether Wiki" "https://aether.wiki.gg/wiki/Aether_Wiki" #f #f) (extwiki^ '("before-darkness-falls") 'empty 'empty "Before Darkness Falls Wiki" "https://beforedarknessfalls.wiki.gg/wiki/Before_Darkness_Falls_Wiki" #f #f) From b8ccd6cc3e691b6b58a2156c2b210ab5bb433423 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 3 Oct 2023 18:54:07 +1300 Subject: [PATCH 5/8] Improve theme layout on non-flex browsers --- src/application-globals.rkt | 4 ++-- static/main.css | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/application-globals.rkt b/src/application-globals.rkt index 10b4530..de60820 100644 --- a/src/application-globals.rkt +++ b/src/application-globals.rkt @@ -240,7 +240,7 @@ (div (@ (class "bw-ss__container") (id "bw-pr-search-suggestions")))) (div (@ (class "bw-theme__select")) (span (@ (class "bw-theme__main-label")) "Page theme") - (div (@ (class "bw-theme__items")) + (span (@ (class "bw-theme__items")) ,@(for/list ([theme '(default light dark)]) (define class (if (equal? theme (user-cookies^-theme user-cookies)) @@ -251,7 +251,7 @@ req (struct-copy user-cookies^ user-cookies [theme theme]))) (class ,class)) - (div (@ (class "bw-theme__icon-container")) + (span (@ (class "bw-theme__icon-container")) ,(hash-ref theme-icons theme)) ,(format "~a" theme))))))) (div (@ (id "content") #;(class "page-content")) diff --git a/static/main.css b/static/main.css index 1641886..cb32df5 100644 --- a/static/main.css +++ b/static/main.css @@ -332,6 +332,7 @@ a.ext-audiobutton { /* see hearthstone/wiki/Diablo_(Duels_hero) */ display: flex; } .bw-theme__item { + display: inline-block; display: flex; align-items: baseline; padding: 2px; From 9773e62c46b3faebb8e621718f3e9870fbd24d10 Mon Sep 17 00:00:00 2001 From: blankie Date: Mon, 29 May 2023 23:02:28 +0700 Subject: [PATCH 6/8] Add better support for tabs Some pages break without actual tab support, such as https://breezewiki.com/ben10/wiki/Ultimatrix_(Original)#Modes This change aims to work with old browsers (such as Firefox for Android 68) and browsers with Javascript disabled (by showing all tab contents and hiding the tab bar, i.e. how tabs work before this change). --- src/application-globals.rkt | 3 +- static/main.css | 6 ++-- static/tabs.js | 63 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 static/tabs.js diff --git a/src/application-globals.rkt b/src/application-globals.rkt index de60820..a413785 100644 --- a/src/application-globals.rkt +++ b/src/application-globals.rkt @@ -203,10 +203,11 @@ `(script (@ (type "module") (src ,(get-static-url "search-suggestions.js")))) "") (script (@ (type "module") (src ,(get-static-url "countdown.js")))) + (script (@ (defer) (src ,(get-static-url "tabs.js")))) (link (@ (rel "icon") (href ,(u (λ (v) (config-true? 'strict_proxy)) (λ (v) (u-proxy-url v)) (head-data^-icon-url head-data)))))) - (body (@ (class ,(head-data^-body-class head-data))) + (body (@ (class ,(head-data^-body-class head-data) " bw-tabs-nojs")) ,(let ([extension-eligible? (cond/var [(not req) #f] diff --git a/static/main.css b/static/main.css index cb32df5..6b07d2b 100644 --- a/static/main.css +++ b/static/main.css @@ -202,11 +202,11 @@ figcaption, .lightbox-caption, .thumbcaption { padding: 0; } -/* show tabs always */ -.wds-tabs__wrapper { +/* show tabs if tabs.js isn't loaded */ +.bw-tabs-nojs .wds-tabs__wrapper { display: none; } -.wds-tab__content { +.bw-tabs-nojs .wds-tab__content { display: block; } diff --git a/static/tabs.js b/static/tabs.js new file mode 100644 index 0000000..589261d --- /dev/null +++ b/static/tabs.js @@ -0,0 +1,63 @@ +"use strict"; + +function handleTabber(tabber) { + let [tabs, contents] = getTabs(tabber); + + for (let i in tabs) { + let tab = tabs[i]; + let content = contents[i]; + tab.addEventListener("click", function(e) { + let [currentTab, currentContent] = getCurrentTab(tabber); + if (currentTab) { + currentTab.classList.remove("wds-is-current"); + } + if (currentContent) { + currentContent.classList.remove("wds-is-current"); + } + + tab.classList.add("wds-is-current"); + content.classList.add("wds-is-current"); + e.preventDefault(); + }); + } +} + +for (let tabber of document.body.querySelectorAll(".wds-tabber")) { + handleTabber(tabber); +} +document.body.classList.remove("bw-tabs-nojs"); + + + +function getTabs(tabber) { + let tabs = []; + let contents = []; + + for (let i of tabber.querySelector(".wds-tabs__wrapper").querySelectorAll(".wds-tabs__tab")) { + tabs.push(i); + } + for (let i of tabber.children) { + if (!i.matches(".wds-tab__content")) { + continue; + } + contents.push(i); + } + + return [tabs, contents]; +} + +function getCurrentTab(tabber) { + let tab = null; + let content = null; + + tab = tabber.querySelector(".wds-tabs__wrapper").querySelector(".wds-tabs__tab.wds-is-current"); + for (let i of tabber.children) { + if (!i.matches(".wds-tab__content.wds-is-current")) { + continue; + } + content = i; + break; + } + + return [tab, content]; +} From ead6896818be96048138d0d3ecd12438f8d475b8 Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 30 May 2023 13:41:49 +0700 Subject: [PATCH 7/8] Add the ability to specify/open the last open tab in the URL --- static/tabs.js | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/static/tabs.js b/static/tabs.js index 589261d..916cb4d 100644 --- a/static/tabs.js +++ b/static/tabs.js @@ -1,30 +1,23 @@ "use strict"; -function handleTabber(tabber) { +let tabToFind = location.hash.length > 1 ? location.hash.substring(1) : null; +for (let tabber of document.body.querySelectorAll(".wds-tabber")) { let [tabs, contents] = getTabs(tabber); for (let i in tabs) { let tab = tabs[i]; let content = contents[i]; - tab.addEventListener("click", function(e) { - let [currentTab, currentContent] = getCurrentTab(tabber); - if (currentTab) { - currentTab.classList.remove("wds-is-current"); - } - if (currentContent) { - currentContent.classList.remove("wds-is-current"); - } - tab.classList.add("wds-is-current"); - content.classList.add("wds-is-current"); + tab.addEventListener("click", function(e) { + setCurrentTab(tabber, tab, content); e.preventDefault(); }); + if (tab.dataset.hash === tabToFind) { + setCurrentTab(tabber, tab, content); + tabToFind = null; + } } } - -for (let tabber of document.body.querySelectorAll(".wds-tabber")) { - handleTabber(tabber); -} document.body.classList.remove("bw-tabs-nojs"); @@ -61,3 +54,18 @@ function getCurrentTab(tabber) { return [tab, content]; } + +function setCurrentTab(tabber, tab, content) { + let [currentTab, currentContent] = getCurrentTab(tabber); + if (currentTab) { + currentTab.classList.remove("wds-is-current"); + } + if (currentContent) { + currentContent.classList.remove("wds-is-current"); + } + + tab.classList.add("wds-is-current"); + content.classList.add("wds-is-current"); + location.hash = "#" + tab.dataset.hash; + history.pushState(null, "", "#" + tab.dataset.hash); +} From f5399524b135eedf346ad758a88f37cba57be700 Mon Sep 17 00:00:00 2001 From: blankie Date: Tue, 30 May 2023 14:01:14 +0700 Subject: [PATCH 8/8] Prevent linking to tabs with no IDs --- static/tabs.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/tabs.js b/static/tabs.js index 916cb4d..6f582e8 100644 --- a/static/tabs.js +++ b/static/tabs.js @@ -14,7 +14,6 @@ for (let tabber of document.body.querySelectorAll(".wds-tabber")) { }); if (tab.dataset.hash === tabToFind) { setCurrentTab(tabber, tab, content); - tabToFind = null; } } } @@ -66,6 +65,8 @@ function setCurrentTab(tabber, tab, content) { tab.classList.add("wds-is-current"); content.classList.add("wds-is-current"); - location.hash = "#" + tab.dataset.hash; - history.pushState(null, "", "#" + tab.dataset.hash); + if (tab.dataset.hash) { + location.hash = "#" + tab.dataset.hash; + history.pushState(null, "", "#" + tab.dataset.hash); + } }