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