mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2025-10-07 07:22:37 +02:00
var to const
This commit is contained in:
parent
833cffdd2c
commit
0e602fc159
@ -28,12 +28,6 @@
|
||||
"never"
|
||||
],
|
||||
"simple-import-sort/imports": "error",
|
||||
"simple-import-sort/exports": "error",
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"semi": false
|
||||
}
|
||||
]
|
||||
"simple-import-sort/exports": "error"
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@ import archives from './archives.json'
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
var Redirect = {
|
||||
const Redirect = {
|
||||
archives,
|
||||
|
||||
init() {
|
||||
|
||||
@ -4,7 +4,7 @@ import type Post from '../classes/Post'
|
||||
import Config from '../config/Config'
|
||||
import Get from '../General/Get'
|
||||
import Settings from '../General/Settings'
|
||||
import { Conf, doc,g } from '../globals/globals'
|
||||
import { Conf, doc, g } from '../globals/globals'
|
||||
import Menu from '../Menu/Menu'
|
||||
import Unread from '../Monitoring/Unread'
|
||||
import $ from '../platform/$'
|
||||
@ -52,7 +52,7 @@ type FilterType =
|
||||
| 'filesize'
|
||||
| 'MD5'
|
||||
|
||||
var Filter = {
|
||||
const Filter = {
|
||||
/**
|
||||
* Uses a Map for string types, with the value to filter for as the key.
|
||||
* This allows faster lookup than iterating over every filter.
|
||||
@ -183,7 +183,7 @@ var Filter = {
|
||||
if (!this.filters.size) return
|
||||
|
||||
// conversion from array to map for string types
|
||||
for (const type of ['MD5', 'uniqueID'] satisfies FilterType[]) {
|
||||
for (const type of ['MD5', 'uniqueID']satisfies FilterType[]) {
|
||||
const filtersForType = this.filters.get(type)
|
||||
if (!filtersForType) continue
|
||||
|
||||
@ -352,10 +352,9 @@ var Filter = {
|
||||
if (![200, 404].includes(this.status)) {
|
||||
new Notice(
|
||||
'warning',
|
||||
`Failed to fetch catalog JSON data. ${
|
||||
this.status
|
||||
? `Error ${this.statusText} (${this.status})`
|
||||
: 'Connection Error'
|
||||
`Failed to fetch catalog JSON data. ${this.status
|
||||
? `Error ${this.statusText} (${this.status})`
|
||||
: 'Connection Error'
|
||||
}`,
|
||||
1
|
||||
)
|
||||
@ -659,7 +658,7 @@ var Filter = {
|
||||
['Image dimensions', 'dimensions'],
|
||||
['Filesize', 'filesize'],
|
||||
['Image MD5', 'MD5'],
|
||||
] satisfies [string, FilterType][]) {
|
||||
]satisfies[string, FilterType][]) {
|
||||
// Add a sub entry for each filter type.
|
||||
entry.subEntries.push(Filter.menu.createSubEntry(type[0], type[1]))
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import Recursive from './Recursive'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var PostHiding = {
|
||||
const PostHiding = {
|
||||
init() {
|
||||
if (
|
||||
!['index', 'thread'].includes(g.VIEW) ||
|
||||
|
||||
@ -8,7 +8,7 @@ import { dict } from '../platform/helpers'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Recursive = {
|
||||
const Recursive = {
|
||||
recursives: dict(),
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW)) {
|
||||
|
||||
@ -10,7 +10,7 @@ import $ from '../platform/$'
|
||||
import $$ from '../platform/$$'
|
||||
import { dict } from '../platform/helpers'
|
||||
|
||||
var ThreadHiding = {
|
||||
const ThreadHiding = {
|
||||
init() {
|
||||
if (
|
||||
!['index', 'catalog'].includes(g.VIEW) ||
|
||||
|
||||
@ -9,7 +9,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var FappeTyme = {
|
||||
const FappeTyme = {
|
||||
init() {
|
||||
if (
|
||||
(!Conf['Fappe Tyme'] && !Conf['Werk Tyme']) ||
|
||||
|
||||
@ -21,7 +21,7 @@ import ImageCommon from './ImageCommon'
|
||||
import Sauce from './Sauce'
|
||||
import Volume from './Volume'
|
||||
|
||||
var Gallery = {
|
||||
const Gallery = {
|
||||
init() {
|
||||
if (
|
||||
!(this.enabled = Conf['Gallery'] && ['index', 'thread'].includes(g.VIEW))
|
||||
|
||||
@ -14,7 +14,7 @@ import Volume from './Volume'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ImageCommon = {
|
||||
const ImageCommon = {
|
||||
// Pause and mute video in preparation for removing the element from the document.
|
||||
pause(video) {
|
||||
if (video.nodeName !== 'VIDEO') {
|
||||
|
||||
@ -16,7 +16,7 @@ import Volume from './Volume'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ImageExpand = {
|
||||
const ImageExpand = {
|
||||
init() {
|
||||
if (
|
||||
!(this.enabled =
|
||||
|
||||
@ -7,7 +7,7 @@ import $$ from '../platform/$$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ImageHost = {
|
||||
const ImageHost = {
|
||||
init() {
|
||||
if (
|
||||
!(this.useFaster = /\S/.test(Conf['fourchanImageHost'])) ||
|
||||
|
||||
@ -13,7 +13,7 @@ import Volume from './Volume'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ImageHover = {
|
||||
const ImageHover = {
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW)) {
|
||||
return
|
||||
|
||||
@ -9,7 +9,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ImageLoader = {
|
||||
const ImageLoader = {
|
||||
init() {
|
||||
if (!['index', 'thread', 'archive'].includes(g.VIEW)) {
|
||||
return
|
||||
|
||||
@ -10,7 +10,7 @@ import CrossOrigin from '../platform/CrossOrigin'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Metadata = {
|
||||
const Metadata = {
|
||||
init() {
|
||||
if (!Conf['WEBM Metadata'] || !['index', 'thread'].includes(g.VIEW)) {
|
||||
return
|
||||
|
||||
@ -13,7 +13,7 @@ import { dict } from '../platform/helpers'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Sauce = {
|
||||
const Sauce = {
|
||||
init() {
|
||||
let link
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Sauce']) {
|
||||
|
||||
@ -10,7 +10,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Volume = {
|
||||
const Volume = {
|
||||
init() {
|
||||
if (
|
||||
!['index', 'thread'].includes(g.VIEW) ||
|
||||
|
||||
@ -18,7 +18,7 @@ import EmbeddingPage from './Embedding/Embed.html'
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
var Embedding = {
|
||||
const Embedding = {
|
||||
init() {
|
||||
if (
|
||||
!['index', 'thread', 'archive'].includes(g.VIEW) ||
|
||||
|
||||
@ -12,7 +12,7 @@ import Embedding from './Embedding'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Linkify = {
|
||||
const Linkify = {
|
||||
init() {
|
||||
if (!['index', 'thread', 'archive'].includes(g.VIEW) || !Conf['Linkify']) {
|
||||
return
|
||||
|
||||
@ -10,7 +10,7 @@ import Menu from './Menu'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var DeleteLink = {
|
||||
const DeleteLink = {
|
||||
auto: [dict(), dict()],
|
||||
|
||||
init() {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import Callbacks from '../classes/Callbacks'
|
||||
import Post from '../classes/Post'
|
||||
import UI from '../General/UI'
|
||||
import { Conf,g } from '../globals/globals'
|
||||
import { Conf, g } from '../globals/globals'
|
||||
import $ from '../platform/$'
|
||||
|
||||
var Menu: any = {
|
||||
const Menu: any = {
|
||||
init(): VoidFunction {
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Menu']) {
|
||||
return
|
||||
|
||||
@ -46,7 +46,7 @@ import xat_unreadSFWY from './Favicon/xat-.unreadSFWY.png'
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
var Favicon = {
|
||||
const Favicon = {
|
||||
init() {
|
||||
return $.asap(
|
||||
() => d.head && (Favicon.el = $('link[rel="shortcut icon"]', d.head)),
|
||||
|
||||
@ -2,7 +2,7 @@ import Callbacks from '../classes/Callbacks'
|
||||
import { Conf, d, g } from '../globals/globals'
|
||||
import $ from '../platform/$'
|
||||
|
||||
var MarkNewIPs = {
|
||||
const MarkNewIPs = {
|
||||
init() {
|
||||
if (
|
||||
g.SITE.software !== 'yotsuba' ||
|
||||
|
||||
@ -5,7 +5,7 @@ import { Conf, d,E, g } from '../globals/globals'
|
||||
import $ from '../platform/$'
|
||||
import QuoteThreading from '../Quotelinks/QuoteThreading'
|
||||
|
||||
var ReplyPruning = {
|
||||
const ReplyPruning = {
|
||||
init() {
|
||||
if (g.VIEW !== 'thread' || !Conf['Reply Pruning']) {
|
||||
return
|
||||
|
||||
@ -10,7 +10,7 @@ import { MINUTE, SECOND } from '../platform/helpers'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var ThreadStats = {
|
||||
const ThreadStats = {
|
||||
postCount: 0,
|
||||
fileCount: 0,
|
||||
postIndex: 0,
|
||||
|
||||
@ -21,7 +21,7 @@ import Unread from './Unread'
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
var ThreadUpdater = {
|
||||
const ThreadUpdater = {
|
||||
init() {
|
||||
let el, name, sc
|
||||
if (g.VIEW !== 'thread' || !Conf['Thread Updater']) {
|
||||
|
||||
@ -21,7 +21,7 @@ import ThreadWatcherPage from './ThreadWatcher/ThreadWatcher.html'
|
||||
import Unread from './Unread'
|
||||
import UnreadIndex from './UnreadIndex'
|
||||
|
||||
var ThreadWatcher = {
|
||||
const ThreadWatcher = {
|
||||
db: null as DataBoard,
|
||||
dbLM: null as DataBoard,
|
||||
dialog: null as HTMLDivElement,
|
||||
@ -289,7 +289,7 @@ var ThreadWatcher = {
|
||||
} else if (Conf['Auto Watch Reply']) {
|
||||
return ThreadWatcher.add(
|
||||
g.threads.get(boardID + '.' + threadID) ||
|
||||
new Thread(threadID + '', boardID),
|
||||
new Thread(threadID + '', boardID),
|
||||
cb
|
||||
)
|
||||
}
|
||||
@ -417,7 +417,7 @@ var ThreadWatcher = {
|
||||
const { db } = ThreadWatcher
|
||||
const interval =
|
||||
Conf['Show Page'] ||
|
||||
(ThreadWatcher.unreadEnabled && Conf['Show Unread Count'])
|
||||
(ThreadWatcher.unreadEnabled && Conf['Show Unread Count'])
|
||||
? 5 * MINUTE
|
||||
: 2 * HOUR
|
||||
const now = Date.now()
|
||||
@ -460,8 +460,8 @@ var ThreadWatcher = {
|
||||
delete ThreadWatcher.syncing
|
||||
if (
|
||||
0 >
|
||||
(middle =
|
||||
Date.now() - (ThreadWatcher.db.data.lastChecked || 0)) ||
|
||||
(middle =
|
||||
Date.now() - (ThreadWatcher.db.data.lastChecked || 0)) ||
|
||||
middle >= interval
|
||||
) {
|
||||
// not checked in another tab
|
||||
@ -564,7 +564,7 @@ var ThreadWatcher = {
|
||||
const { threadID, data } = thread
|
||||
if (threads[threadID]) {
|
||||
var index, modified, replies
|
||||
;({ page, index, modified, replies } = threads[threadID])
|
||||
; ({ page, index, modified, replies } = threads[threadID])
|
||||
if (Conf['Show Page']) {
|
||||
const lastPage = g.sites[siteID].isPrunedByAge?.({ siteID, boardID })
|
||||
? threadID === oldest
|
||||
|
||||
@ -16,7 +16,7 @@ import ThreadWatcher from './ThreadWatcher'
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Unread = {
|
||||
const Unread = {
|
||||
init() {
|
||||
if (
|
||||
g.VIEW !== 'thread' ||
|
||||
|
||||
@ -16,7 +16,7 @@ import ThreadWatcher from './ThreadWatcher'
|
||||
* DS205: Consider reworking code to avoid use of IIFEs
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var UnreadIndex = {
|
||||
const UnreadIndex = {
|
||||
lastReadPost: dict(),
|
||||
hr: dict(),
|
||||
markReadLink: dict(),
|
||||
|
||||
@ -11,7 +11,7 @@ import QuoteYou from './QuoteYou'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteBacklink = {
|
||||
const QuoteBacklink = {
|
||||
// Backlinks appending need to work for:
|
||||
// - previous, same, and following posts.
|
||||
// - existing and yet-to-exist posts.
|
||||
|
||||
@ -9,7 +9,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteCT = {
|
||||
const QuoteCT = {
|
||||
init() {
|
||||
if (
|
||||
!['index', 'thread'].includes(g.VIEW) ||
|
||||
|
||||
@ -12,7 +12,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteInline = {
|
||||
const QuoteInline = {
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Quote Inlining']) {
|
||||
return
|
||||
|
||||
@ -9,7 +9,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteOP = {
|
||||
const QuoteOP = {
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Mark OP Quotes']) {
|
||||
return
|
||||
|
||||
@ -13,7 +13,7 @@ import $ from '../platform/$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuotePreview = {
|
||||
const QuotePreview = {
|
||||
init() {
|
||||
if (!Conf['Quote Previewing']) {
|
||||
return
|
||||
|
||||
@ -16,7 +16,7 @@ import { dict } from '../platform/helpers'
|
||||
<3 aeosynth
|
||||
*/
|
||||
|
||||
var QuoteThreading = {
|
||||
const QuoteThreading = {
|
||||
init() {
|
||||
if (!Conf['Quote Threading'] || g.VIEW !== 'thread') {
|
||||
return
|
||||
|
||||
@ -15,7 +15,7 @@ import PostRedirect from '../Posting/PostRedirect'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteYou = {
|
||||
const QuoteYou = {
|
||||
init() {
|
||||
if (!Conf['Remember Your Posts']) {
|
||||
return
|
||||
|
||||
@ -12,7 +12,7 @@ import $$ from '../platform/$$'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Quotify = {
|
||||
const Quotify = {
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Resurrect Quotes']) {
|
||||
return
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import Redirect from '../Archive/Redirect'
|
||||
import Get from '../General/Get'
|
||||
import Index from '../General/Index'
|
||||
import { Conf, d,E, g } from '../globals/globals'
|
||||
import { Conf, d, E, g } from '../globals/globals'
|
||||
import ImageHost from '../Images/ImageHost'
|
||||
import Main from '../main/Main'
|
||||
import $ from '../platform/$'
|
||||
@ -23,7 +23,7 @@ export default class Fetcher {
|
||||
'[/moot]': { innerHTML: string }
|
||||
'[banned]': { innerHTML: string }
|
||||
'[/banned]': { innerHTML: string }
|
||||
'[fortune]'(text: any): { innerHTML: string }
|
||||
'[fortune]'(text: string): { innerHTML: string }
|
||||
'[/fortune]': { innerHTML: string }
|
||||
'[i]': { innerHTML: string }
|
||||
'[/i]': { innerHTML: string }
|
||||
@ -34,11 +34,11 @@ export default class Fetcher {
|
||||
'[blue]': { innerHTML: string }
|
||||
'[/blue]': { innerHTML: string }
|
||||
}
|
||||
boardID: string | number
|
||||
boardID: string
|
||||
threadID: string | number
|
||||
postID: string | number
|
||||
root: HTMLElement
|
||||
quoter: any
|
||||
postID: number
|
||||
root: Document | HTMLElement
|
||||
quoter: HTMLElement | Post
|
||||
static flagCSS: HTMLStyleElement | HTMLElement
|
||||
static initClass() {
|
||||
this.prototype.archiveTags = {
|
||||
@ -75,9 +75,9 @@ export default class Fetcher {
|
||||
'[/blue]': { innerHTML: '</span>' },
|
||||
}
|
||||
}
|
||||
constructor(boardID, threadID, postID, root, quoter) {
|
||||
let post, thread
|
||||
this.boardID = boardID
|
||||
constructor(boardID: number | string, threadID: number, postID: number, root: Document | HTMLElement, quoter: Post) {
|
||||
let post: Post, thread: Thread
|
||||
this.boardID = boardID as string
|
||||
this.threadID = threadID
|
||||
this.postID = postID
|
||||
this.root = root
|
||||
@ -106,22 +106,20 @@ export default class Fetcher {
|
||||
|
||||
this.root.textContent = `Loading post No.${this.postID}...`
|
||||
if (this.threadID) {
|
||||
const that = this
|
||||
Fetcher.fetchThread(
|
||||
this.boardID,
|
||||
this.threadID,
|
||||
function (req) {
|
||||
that.fetchedThread(req)
|
||||
this.fetchedThread(req)
|
||||
},
|
||||
true
|
||||
)
|
||||
} else {
|
||||
const that = this
|
||||
Fetcher.fetchPost(
|
||||
this.boardID,
|
||||
this.postID,
|
||||
function (req, isCached) {
|
||||
that.fetchedPost(req, isCached)
|
||||
this.fetchedPost(req, isCached)
|
||||
},
|
||||
true
|
||||
)
|
||||
@ -161,11 +159,9 @@ export default class Fetcher {
|
||||
return
|
||||
}
|
||||
const thread = new Thread(
|
||||
g.SITE.Build.threadFromObject(response, boardID),
|
||||
board
|
||||
)
|
||||
g.SITE.Build.threadFromObject(response, boardID), board.ID)
|
||||
Main.callbackNodes('Thread', [thread])
|
||||
const post = thread.posts.get(this.postID)
|
||||
const post = thread.posts.get(`${boardID}.${this.postID}`)
|
||||
if (post) {
|
||||
this.insert(post)
|
||||
} else {
|
||||
@ -182,7 +178,7 @@ export default class Fetcher {
|
||||
}
|
||||
const clone = post.addClone(
|
||||
this.quoter.context,
|
||||
$.hasClass(this.root, 'dialog')
|
||||
$.hasClass(this.root.appendChild($.el('div')), 'backlink')
|
||||
)
|
||||
Main.callbackNodes('Post', [clone])
|
||||
|
||||
@ -221,7 +217,7 @@ export default class Fetcher {
|
||||
|
||||
$.rmAll(this.root)
|
||||
$.add(this.root, nodes.root)
|
||||
return $.event('PostsInserted', null, this.root)
|
||||
return $.event('PostsInserted', null, Document.apply(this.root))
|
||||
}
|
||||
|
||||
fetchedPost(req: XMLHttpRequest, isCached: boolean) {
|
||||
@ -252,7 +248,7 @@ export default class Fetcher {
|
||||
|
||||
const board = g.boards[boardID] || new Board(boardID)
|
||||
const threadKey = `${boardID}.${threadID}`
|
||||
const thread = g.threads.get(threadKey) || new Thread(threadID, board)
|
||||
const thread = g.threads.get(threadKey) || new Thread(threadID as string, board)
|
||||
const newPost = new Post(
|
||||
g.SITE.Build.postFromObject(foundPost, boardID),
|
||||
thread,
|
||||
@ -272,10 +268,7 @@ export default class Fetcher {
|
||||
|
||||
handlePostNotFound(isCached: boolean, req?: XMLHttpRequest) {
|
||||
if (isCached) {
|
||||
const api = g.SITE.urls.threadJSON({
|
||||
boardID: this.boardID,
|
||||
threadID: this.threadID,
|
||||
}, true)
|
||||
const api = g.SITE.urls.threadJSON(this.boardID as string, this.threadID as string)
|
||||
$.cleanCache((url: string) => url === api)
|
||||
$.cache(api, () => this.fetchedPost(req, false))
|
||||
return
|
||||
@ -285,7 +278,7 @@ export default class Fetcher {
|
||||
return
|
||||
}
|
||||
|
||||
$.addClass(this.root, 'warning')
|
||||
$.addClass(this.root.appendChild($.el('div')), 'backlink')
|
||||
this.root.textContent = `Post No.${this.postID} was not found.`
|
||||
}
|
||||
|
||||
@ -306,7 +299,6 @@ export default class Fetcher {
|
||||
const encryptionOK =
|
||||
/^https:\/\//.test(url) || location.protocol === 'http:'
|
||||
if (encryptionOK || Conf['Exempt Archives from Encryption']) {
|
||||
const that = this
|
||||
CrossOrigin.cache(url, function () {
|
||||
if (!encryptionOK && this.response?.media) {
|
||||
const { media } = this.response
|
||||
@ -320,14 +312,14 @@ export default class Fetcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
return that.parseArchivedPost(this.response, url, archive)
|
||||
return this.parseArchivedPost(this.response, url, archive)
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
parseArchivedPost(data: any, url, archive: any) {
|
||||
parseArchivedPost(data: any, url: string, archive: any) {
|
||||
// In case of multiple callbacks for the same request,
|
||||
// don't parse the same original post more than once.
|
||||
let post: Post
|
||||
@ -337,13 +329,13 @@ export default class Fetcher {
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
$.addClass(this.root, 'warning')
|
||||
$.addClass(this.root.appendChild($.el('div')), 'backlink')
|
||||
this.root.textContent = `Error fetching Post No.${this.postID} from ${archive.name}.`
|
||||
return
|
||||
}
|
||||
|
||||
if (data.error) {
|
||||
$.addClass(this.root, 'warning')
|
||||
$.addClass(this.root.appendChild($.el('div')), 'backlink')
|
||||
this.root.textContent = data.error
|
||||
return
|
||||
}
|
||||
@ -391,8 +383,14 @@ export default class Fetcher {
|
||||
threadID: this.threadID,
|
||||
boardID: this.boardID,
|
||||
isReply: this.postID !== this.threadID,
|
||||
info: null,
|
||||
file: data.media,
|
||||
time: +data.timestamp,
|
||||
fileDeleted: data.media_status === 'b',
|
||||
extra: null,
|
||||
}
|
||||
o.info = {
|
||||
uniqueID: data.poster_hash,
|
||||
subject: data.title,
|
||||
email: data.email,
|
||||
name: data.name || '',
|
||||
@ -414,7 +412,6 @@ export default class Fetcher {
|
||||
return 'Manager'
|
||||
}
|
||||
})(),
|
||||
uniqueID: data.poster_hash,
|
||||
flagCode: data.poster_country,
|
||||
flagCodeTroll: data.troll_country_code,
|
||||
flag: data.poster_country_name || data.troll_country_name,
|
||||
@ -480,7 +477,7 @@ export default class Fetcher {
|
||||
post = new Post(g.SITE.Build.post(o), thread, board, {
|
||||
isFetchedQuote: true,
|
||||
})
|
||||
post.kill()
|
||||
post.kill(post.file)
|
||||
if (post.file) {
|
||||
post.file.thumbURL = o.file.thumbURL
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import Get from '../General/Get'
|
||||
import { Conf,g } from '../globals/globals'
|
||||
import { Conf, g } from '../globals/globals'
|
||||
import ImageExpand from '../Images/ImageExpand'
|
||||
import $ from '../platform/$'
|
||||
import $$ from '../platform/$$'
|
||||
@ -62,7 +62,7 @@ export default class Post {
|
||||
return this.ID
|
||||
}
|
||||
|
||||
constructor(root?: HTMLElement, thread?: Thread, board?: Board, flags = {}) {
|
||||
constructor(root: HTMLElement, thread?: Thread, board?: Board, flags?: any) {
|
||||
// <% if (readJSON('/.tests_enabled')) { %>
|
||||
// @normalizedOriginal = Test.normalize root
|
||||
// <% } %>
|
||||
@ -180,8 +180,8 @@ export default class Post {
|
||||
archivelinks: HTMLAnchorElement[]
|
||||
embedlinks: HTMLAnchorElement[]
|
||||
backlinks: HTMLCollectionOf<HTMLAnchorElement>
|
||||
uniqueIDRoot: any
|
||||
uniqueID: any
|
||||
uniqueIDRoot: string
|
||||
uniqueID: string
|
||||
}
|
||||
|
||||
const nodes: Node & Partial<Record<keyof Post['info'], HTMLElement>> = {
|
||||
@ -199,8 +199,8 @@ export default class Post {
|
||||
backlinks: post.getElementsByClassName(
|
||||
'backlink'
|
||||
) as HTMLCollectionOf<HTMLAnchorElement>,
|
||||
uniqueIDRoot: undefined as any,
|
||||
uniqueID: undefined as any,
|
||||
uniqueIDRoot: null,
|
||||
uniqueID: null,
|
||||
}
|
||||
for (const key in s.info) {
|
||||
const selector = s.info[key]
|
||||
@ -332,6 +332,7 @@ export default class Post {
|
||||
|
||||
parseFile(fileRoot: HTMLElement) {
|
||||
interface File {
|
||||
thumbURL: string
|
||||
isImage: boolean
|
||||
isVideo: boolean
|
||||
url: string
|
||||
@ -454,7 +455,7 @@ export default class Post {
|
||||
this.board.posts.rm(this)
|
||||
}
|
||||
|
||||
addClone(context, contractThumb) {
|
||||
addClone(context: HTMLElement, contractThumb: boolean): PostClone {
|
||||
// Callbacks may not have been run yet due to anti-browser-lock delay in Main.callbackNodesDB.
|
||||
Callbacks.Post.execute(this)
|
||||
return new PostClone(this, context, contractThumb)
|
||||
@ -482,7 +483,8 @@ export class PostClone extends Post {
|
||||
static suffix = 0
|
||||
|
||||
constructor(origin: Post, context: any, contractThumb: boolean) {
|
||||
super()
|
||||
//super(root, thread, board)
|
||||
super(Document, origin.thread, origin.board)
|
||||
this.isClone = true
|
||||
|
||||
let file: any, fileRoots: HTMLAnchorElement, key: string
|
||||
@ -585,7 +587,7 @@ export class PostClone extends Post {
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE && node.querySelector('video')) {
|
||||
const clone = node.cloneNode(false) as Element
|
||||
for (const child of node.childNodes) {
|
||||
clone.appendChild(cloneWithoutVideo(child))
|
||||
clone.appendChild(this.cloneWithoutVideo(child))
|
||||
}
|
||||
return clone
|
||||
} else {
|
||||
|
||||
@ -15,12 +15,17 @@ export default class SimpleDict<T> {
|
||||
return (this[key] = data)
|
||||
}
|
||||
|
||||
rm(key: string) {
|
||||
let i: number
|
||||
key = `${key}`
|
||||
if ((i = this.keys.indexOf(key)) !== -1) {
|
||||
this.keys.splice(i, 1)
|
||||
return delete this[key]
|
||||
rm(key: string | Object) {
|
||||
if (typeof key === 'string') {
|
||||
key = `${key}`
|
||||
if (this[key]) {
|
||||
delete this[key]
|
||||
this.keys.splice(this.keys.indexOf(key), 1)
|
||||
}
|
||||
} else {
|
||||
for (const k of Object.keys(key)) {
|
||||
this.rm(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ import Quotify from '../Quotelinks/Quotify'
|
||||
import Site from '../site/Site'
|
||||
import SW from '../site/SW'
|
||||
|
||||
var Main = {
|
||||
const Main = {
|
||||
init() {
|
||||
// XXX dwb userscripts extension reloads scripts run at document-start when replaceState/pushState is called.
|
||||
// XXX Firefox reinjects WebExtension content scripts when extension is updated / reloaded.
|
||||
|
||||
@ -13,7 +13,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
||||
}
|
||||
})
|
||||
|
||||
var handlers = {
|
||||
const handlers = {
|
||||
permission(request, cb) {
|
||||
const origins = request.origins || ['*://*/']
|
||||
return chrome.permissions.contains({ origins }, function (result) {
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
ElementProperties,
|
||||
WhenModifiedOptions,
|
||||
} from '../types/$'
|
||||
import { cloneInto } from '../types/globals'
|
||||
import CrossOrigin from './CrossOrigin'
|
||||
import { debounce, dict, MINUTE, platform, SECOND } from './helpers'
|
||||
// not chainable
|
||||
@ -197,7 +198,6 @@ $.ajax = (function () {
|
||||
|
||||
$.ajaxPageInit = function () {
|
||||
$.global(function () {
|
||||
//@ts-ignore
|
||||
window.FCX.requests = Object.create(null)
|
||||
document.addEventListener(
|
||||
'4chanXAjax',
|
||||
@ -214,7 +214,7 @@ $.ajax = (function () {
|
||||
headers,
|
||||
id,
|
||||
} = e.detail
|
||||
//@ts-ignore
|
||||
|
||||
window.FCX.requests[id] = r = new pageXHR()
|
||||
r.open(type, url, true)
|
||||
const object = headers || {}
|
||||
@ -238,7 +238,7 @@ $.ajax = (function () {
|
||||
}
|
||||
}
|
||||
r.onloadend = function () {
|
||||
//@ts-ignore
|
||||
|
||||
delete window.FCX.requests[id]
|
||||
const { status, statusText, response } = this
|
||||
const responseHeaderString = this.getAllResponseHeaders()
|
||||
@ -276,7 +276,7 @@ $.ajax = (function () {
|
||||
'4chanXAjaxAbort',
|
||||
function (e) {
|
||||
let r
|
||||
//@ts-ignore
|
||||
|
||||
if (!(r = window.FCX.requests[e.detail.id])) {
|
||||
return
|
||||
}
|
||||
@ -518,9 +518,9 @@ $.X = function (path: string, root?: HTMLElement) {
|
||||
return d.evaluate(path, root, null, 7, null)
|
||||
}
|
||||
|
||||
$.addClass = function (el: HTMLElement, ...classNames: string[]) {
|
||||
$.addClass = function (el: HTMLElement, ...classNames: string[]): void {
|
||||
for (const className of classNames) {
|
||||
el.classList.add(className)
|
||||
!el.classList.contains(className) && el.classList.add(className)
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,10 +598,10 @@ $.one = function (el, events, handler) {
|
||||
return $.on(el, events, cb)
|
||||
}
|
||||
|
||||
$.event = function (event, detail, root = d) {
|
||||
$.event = function (event: string, detail: any, root: Document = d) {
|
||||
if (!globalThis.chrome?.extension) {
|
||||
if (detail != null && typeof cloneInto === 'function') {
|
||||
detail = cloneInto(detail, d.defaultView)
|
||||
detail = cloneInto(detail, root.defaultView)
|
||||
}
|
||||
}
|
||||
return root.dispatchEvent(
|
||||
|
||||
@ -9,7 +9,7 @@ import SW from './SW'
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Site = {
|
||||
const Site = {
|
||||
defaultProperties: {
|
||||
'4chan.org': { software: 'yotsuba' },
|
||||
'4channel.org': { canonical: '4chan.org' },
|
||||
|
||||
6
src/types/globals.d.ts
vendored
6
src/types/globals.d.ts
vendored
@ -1,2 +1,8 @@
|
||||
declare const cloneInto: Function
|
||||
declare const XPCNativeWrapper: any
|
||||
export interface threeClover {
|
||||
siteID: string
|
||||
boardID: string
|
||||
threadID: string
|
||||
}
|
||||
|
||||
|
||||
@ -9,17 +9,20 @@
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"strict": false,
|
||||
"jsx": "react",
|
||||
"jsxFactory": "jsx",
|
||||
"jsxFragmentFactory": "h",
|
||||
"jsxFactory": "h",
|
||||
"jsxFragmentFactory": "hFragment",
|
||||
"types": [
|
||||
"@violentmonkey/types",
|
||||
"@types/chrome",
|
||||
"@types/jquery",
|
||||
"@types/node"
|
||||
],
|
||||
"lib": ["DOM", "ES2020"],
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ES2020"
|
||||
],
|
||||
"outDir": "builds/test/crx/tsOutput",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
@ -29,4 +32,4 @@
|
||||
"./tools/*",
|
||||
"dist/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user