From f869225c41133e107ae644bcb1cb00e42b85598c Mon Sep 17 00:00:00 2001 From: Lalle <29478339+LalleSX@users.noreply.github.com> Date: Sat, 6 May 2023 01:36:05 +0200 Subject: [PATCH] bugsfixes and add types --- src/Archive/Redirect.ts | 4 +++- src/General/Get.ts | 1 + src/Menu/Menu.ts | 1 + src/Miscellaneous/AntiAutoplay.ts | 2 +- src/Miscellaneous/FileInfo.tsx | 2 +- src/Miscellaneous/IDColor.ts | 2 +- src/Miscellaneous/PSA.ts | 13 +++++++------ src/Miscellaneous/PassMessage.ts | 12 ++++++------ src/Quotelinks/QuoteCT.ts | 1 + src/Quotelinks/QuoteOP.ts | 1 + src/site/SW.tinyboard.ts | 1 + src/site/Site.ts | 2 +- src/types/globals.d.ts | 1 + 13 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/Archive/Redirect.ts b/src/Archive/Redirect.ts index 09c03b2..2d6b05c 100644 --- a/src/Archive/Redirect.ts +++ b/src/Archive/Redirect.ts @@ -12,6 +12,8 @@ import archives from './archives.json' const Redirect = { archives, + selectedArchives: dict(), + data: dict(), init() { this.selectArchives() @@ -122,7 +124,7 @@ const Redirect = { } } const items = { archives, lastarchivecheck: Date.now() } - $.set(items) + $.set(Conf, items, true) $.extend(Conf, items) Redirect.selectArchives() return cb diff --git a/src/General/Get.ts b/src/General/Get.ts index 5e190aa..6ea0479 100644 --- a/src/General/Get.ts +++ b/src/General/Get.ts @@ -1,4 +1,5 @@ import Post from "../classes/Post" +import Thread from "../classes/Thread" import { Conf, g } from "../globals/globals" import $ from "../platform/$" diff --git a/src/Menu/Menu.ts b/src/Menu/Menu.ts index a522aa0..d27832f 100644 --- a/src/Menu/Menu.ts +++ b/src/Menu/Menu.ts @@ -6,6 +6,7 @@ import $ from "../platform/$" const Menu = { + menu: null, init() { if (!['index', 'thread'].includes(g.VIEW) || !Conf['Menu']) { return } diff --git a/src/Miscellaneous/AntiAutoplay.ts b/src/Miscellaneous/AntiAutoplay.ts index d7669f2..58d0aa8 100644 --- a/src/Miscellaneous/AntiAutoplay.ts +++ b/src/Miscellaneous/AntiAutoplay.ts @@ -18,7 +18,7 @@ const AntiAutoplay = { name: 'Disable Autoplaying Sounds', cb: this.node }) - return $.ready(() => this.process(d.body)) + return $.ready(() => this.process(document.body)) }, stop(audio) { diff --git a/src/Miscellaneous/FileInfo.tsx b/src/Miscellaneous/FileInfo.tsx index 30ac653..f3b9765 100644 --- a/src/Miscellaneous/FileInfo.tsx +++ b/src/Miscellaneous/FileInfo.tsx @@ -67,7 +67,7 @@ const FileInfo = { L() { return {FileInfo.formatters.N.call(this)} }, n() { const fullname = this.file.name - const shortname = SW.yotsuba.Build.shortFilename(this.file.name, this.isReply) + const shortname = SW.yotsuba.Build.shortFilename(this.file.name) if (fullname === shortname) { return { innerHTML: E(fullname), [isEscaped]: true } } else { diff --git a/src/Miscellaneous/IDColor.ts b/src/Miscellaneous/IDColor.ts index c5a3879..5afaed4 100644 --- a/src/Miscellaneous/IDColor.ts +++ b/src/Miscellaneous/IDColor.ts @@ -19,7 +19,7 @@ const IDColor = { cb: this.node }) }, - + ids: dict(), node() { let span, uid if (this.isClone || !((uid = this.info.uniqueID) && (span = this.nodes.uniqueID))) { return } diff --git a/src/Miscellaneous/PSA.ts b/src/Miscellaneous/PSA.ts index 2611ffd..93e37c0 100644 --- a/src/Miscellaneous/PSA.ts +++ b/src/Miscellaneous/PSA.ts @@ -1,5 +1,5 @@ import Notice from "../classes/Notice" -import { Conf, doc,g } from "../globals/globals" +import { Conf, doc, g } from "../globals/globals" import Main from "../main/Main" import $ from "../platform/$" @@ -8,17 +8,18 @@ const PSA = { init() { let el if ((g.SITE.software === 'yotsuba') && (g.BOARD.ID === 'qa')) { - const announcement = {innerHTML: "Stay in touch with your /qa/ friends!"} - el = $.el('div', {className: 'fcx-announcement'}, announcement) + const announcement = { innerHTML: "Stay in touch with your /qa/ friends!" } + el = $.el('div', { className: 'fcx-announcement' }, announcement) $.onExists(doc, '.boardBanner', banner => $.after(banner, el)) } if ('samachan.org' in Conf['siteProperties'] && !Conf['PSAseen'].includes('samachan')) { el = $.el('span', - {innerHTML: "Looking for a new home?
Some former Samachan users are regrouping on SushiChan.

(a message from 4chan X)"}) - return Main.ready(function() { + { innerHTML: "Looking for a new home?
Some former Samachan users are regrouping on SushiChan.

(a message from 4chan X)" }) + return Main.ready(function () { new Notice('info', el) Conf['PSAseen'].push('samachan') - return $.set('PSAseen', Conf['PSAseen'])}) + return $.set('PSAseen', Conf['PSAseen'], true) + }) } } } diff --git a/src/Miscellaneous/PassMessage.ts b/src/Miscellaneous/PassMessage.ts index 7f427ca..0aad4d8 100644 --- a/src/Miscellaneous/PassMessage.ts +++ b/src/Miscellaneous/PassMessage.ts @@ -7,17 +7,17 @@ const PassMessage = { init() { if (Conf['passMessageClosed']) { return } const msg = $.el('div', - {className: 'box-outer top-box'} - , + { className: 'box-outer top-box' } + , PassMessagePage) msg.style.cssText = 'padding-bottom: 0;' const close = $('a', msg) - $.on(close, 'click', function() { + $.on(close, 'click', function () { $.rm(msg) - return $.set('passMessageClosed', true) + return $.set('passMessageClosed', Conf, true) }) - return $.ready(function() { - let hd + return $.ready(function () { + let hd: HTMLElement if (hd = $.id('hd')) { return $.after(hd, msg) } else { diff --git a/src/Quotelinks/QuoteCT.ts b/src/Quotelinks/QuoteCT.ts index 97b8a9f..b398e40 100644 --- a/src/Quotelinks/QuoteCT.ts +++ b/src/Quotelinks/QuoteCT.ts @@ -6,6 +6,7 @@ import $ from "../platform/$" const QuoteCT = { + mark: null, init() { if (!['index', 'thread'].includes(g.VIEW) || !Conf['Mark Cross-thread Quotes']) { return } diff --git a/src/Quotelinks/QuoteOP.ts b/src/Quotelinks/QuoteOP.ts index 9a5c667..b5e5241 100644 --- a/src/Quotelinks/QuoteOP.ts +++ b/src/Quotelinks/QuoteOP.ts @@ -10,6 +10,7 @@ import $ from "../platform/$" * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ const QuoteOP = { + mark: null, init() { if (!['index', 'thread'].includes(g.VIEW) || !Conf['Mark OP Quotes']) { return } diff --git a/src/site/SW.tinyboard.ts b/src/site/SW.tinyboard.ts index 4959c03..b6ad492 100644 --- a/src/site/SW.tinyboard.ts +++ b/src/site/SW.tinyboard.ts @@ -193,6 +193,7 @@ const SWTinyboard = { }, xpath: { + post: 'div[starts-with(@id,"reply_")]', thread: 'div[starts-with(@id,"thread_")]', postContainer: 'div[starts-with(@id,"reply_") or starts-with(@id,"thread_")]', replyContainer: 'div[starts-with(@id,"reply_")]' diff --git a/src/site/Site.ts b/src/site/Site.ts index 5766f1f..074e3ba 100644 --- a/src/site/Site.ts +++ b/src/site/Site.ts @@ -41,7 +41,7 @@ const Site = { } } if (changed) { - $.set('siteProperties', Conf['siteProperties']) + $.set('siteProperties', Conf['siteProperties'], true) } if (!g.SITE) { this.set(hostname) diff --git a/src/types/globals.d.ts b/src/types/globals.d.ts index b39884f..025c7c4 100644 --- a/src/types/globals.d.ts +++ b/src/types/globals.d.ts @@ -1,5 +1,6 @@ declare const XPCNativeWrapper: any export interface File { + name: string isImage: boolean isVideo: boolean thumb: HTMLElement