mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2026-03-20 01:37:47 +01:00
QR types cast
This commit is contained in:
parent
64e532a31a
commit
d46c6e42c2
@ -2,12 +2,6 @@ import DataBoard from '../classes/DataBoard'
|
|||||||
import { Conf, d, g } from '../globals/globals'
|
import { Conf, d, g } from '../globals/globals'
|
||||||
import $ from '../platform/$'
|
import $ from '../platform/$'
|
||||||
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS101: Remove unnecessary use of Array.from
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const PostSuccessful = {
|
const PostSuccessful = {
|
||||||
init() {
|
init() {
|
||||||
if (!Conf['Remember Your Posts']) {
|
if (!Conf['Remember Your Posts']) {
|
||||||
|
|||||||
@ -24,8 +24,83 @@ import { DAY, dict, SECOND } 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
|
||||||
*/
|
*/
|
||||||
|
interface QR {
|
||||||
var QR = {
|
initReady(initReady: boolean): any;
|
||||||
|
postingIsEnabled: boolean;
|
||||||
|
nodes: any;
|
||||||
|
open(): unknown;
|
||||||
|
close(): unknown;
|
||||||
|
captcha: { init(): any; moreNeeded(): void; getThread(): { boardID: string; threadID: string }; setup(focus: any): any; destroy(): boolean; updateThread(): any; getOne(): {}; setUsed(): any; occupied(): boolean } | { lifetime: number; init(): void; timeouts: {}; prevNeeded: number; noscriptURL(): string; moreNeeded(): void; toggle(): any; setup(focus: any, force: any): any; setupNoscript(): any; setupJS(): any; afterSetup(mutations: any): void; setupIFrame(iframe: any): void; fixQRPosition(): string; setupTextArea(textarea: any): void; destroy(): boolean; getOne(isReply: any): any; save(pasted: any, token: any): any; count(): void; reload(): any; occupied(): boolean };
|
||||||
|
min_width: number;
|
||||||
|
min_height: number;
|
||||||
|
max_width: number;
|
||||||
|
max_height: number;
|
||||||
|
max_size: number;
|
||||||
|
max_size_video: number;
|
||||||
|
max_comment: number;
|
||||||
|
max_width_video: number;
|
||||||
|
max_height_video: number;
|
||||||
|
max_duration_video: number;
|
||||||
|
forcedAnon: boolean;
|
||||||
|
spoiler: boolean;
|
||||||
|
link: any;
|
||||||
|
getFile(d: Document, arg1: string, getFile: any): unknown;
|
||||||
|
drawFile(d: Document, arg1: string, drawFile: any): unknown;
|
||||||
|
setFile(d: Document, arg1: string, setFile: any): unknown;
|
||||||
|
paste(d: Document, arg1: string, paste: any): unknown;
|
||||||
|
dragOver(d: Document, arg1: string, dragOver: any): unknown;
|
||||||
|
dropFile(d: Document, arg1: string, dropFile: any): unknown;
|
||||||
|
drag(d: Document, arg1: string, drag: any): unknown;
|
||||||
|
generatePostableThreadsList(d: Document, arg1: string, generatePostableThreadsList: any): unknown;
|
||||||
|
statusCheck(d: Document, arg1: string, statusCheck: any): unknown;
|
||||||
|
hide(): unknown;
|
||||||
|
posts: any;
|
||||||
|
abort(): void;
|
||||||
|
status(): void;
|
||||||
|
quote(quote: any, arg1: string, quote1: any): unknown;
|
||||||
|
unhide(): unknown;
|
||||||
|
dialog(): unknown;
|
||||||
|
shortcut(shortcut: any, arg1: string): unknown;
|
||||||
|
req: any;
|
||||||
|
cleanNotifications(): unknown;
|
||||||
|
blur(): unknown;
|
||||||
|
post: any;
|
||||||
|
cooldown: any;
|
||||||
|
inBubble(): unknown;
|
||||||
|
hasFocus: any;
|
||||||
|
texPreviewHide(): unknown;
|
||||||
|
setCustomCooldown(enabled: any): unknown;
|
||||||
|
notifications: any;
|
||||||
|
selected: any;
|
||||||
|
openPost(): unknown;
|
||||||
|
openError(): unknown;
|
||||||
|
error(div: any): unknown;
|
||||||
|
handleFiles(arg0: any[]): unknown;
|
||||||
|
extensionFromType(extensionFromType: any, type: any): unknown;
|
||||||
|
handleUrl(src: any): unknown;
|
||||||
|
handleFile(file: any, length: any): unknown;
|
||||||
|
flagsInput(): unknown;
|
||||||
|
toggleHide(autohide: any, arg1: string, toggleHide: any): unknown;
|
||||||
|
submit(status: any, arg1: string, submit: any): unknown;
|
||||||
|
toggleSJIS(sjisToggle: any, arg1: string, toggleSJIS: any): unknown;
|
||||||
|
texPreviewShow(texButton: any, arg1: string, texPreviewShow: any): unknown;
|
||||||
|
oekaki: any;
|
||||||
|
openFileInput(fileButton: any, arg1: string, openFileInput: any): unknown;
|
||||||
|
toggleCustomCooldown(customCooldown: any, arg1: string, toggleCustomCooldown: any): unknown;
|
||||||
|
focus(arg0: string, focus: any, arg2: boolean): unknown;
|
||||||
|
pasteFF: MutationCallback;
|
||||||
|
persona: any;
|
||||||
|
flags(): unknown;
|
||||||
|
response: any;
|
||||||
|
currentCaptcha: any;
|
||||||
|
connectionError(): any;
|
||||||
|
errorCount: any;
|
||||||
|
waitForThread(URL: string, open: (() => Window | VMScriptGMTabControl) | (() => string)): unknown;
|
||||||
|
characterCount(): unknown;
|
||||||
|
validExtension(validExtension: any): any;
|
||||||
|
mimeTypes: any;
|
||||||
|
}
|
||||||
|
var QR: QR = {
|
||||||
mimeTypes: [
|
mimeTypes: [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/png',
|
'image/png',
|
||||||
@ -35,8 +110,9 @@ var QR = {
|
|||||||
'application/x-shockwave-flash',
|
'application/x-shockwave-flash',
|
||||||
'video/webm',
|
'video/webm',
|
||||||
],
|
],
|
||||||
|
validExtension: function (ext: string) {
|
||||||
validExtension: /\.(jpe?g|png|gif|pdf|swf|webm)$/i,
|
return this.mimeTypes.includes(this.typeFromExtension[ext])
|
||||||
|
},
|
||||||
|
|
||||||
typeFromExtension: {
|
typeFromExtension: {
|
||||||
jpg: 'image/jpeg',
|
jpg: 'image/jpeg',
|
||||||
@ -48,14 +124,21 @@ var QR = {
|
|||||||
webm: 'video/webm',
|
webm: 'video/webm',
|
||||||
},
|
},
|
||||||
|
|
||||||
extensionFromType: {
|
extensionFromType: function (type: string) {
|
||||||
'image/jpeg': 'jpg',
|
switch (type) {
|
||||||
'image/png': 'png',
|
case 'image/jpeg':
|
||||||
'image/gif': 'gif',
|
return 'jpg'
|
||||||
'application/pdf': 'pdf',
|
case 'image/png':
|
||||||
'application/vnd.adobe.flash.movie': 'swf',
|
return 'png'
|
||||||
'application/x-shockwave-flash': 'swf',
|
case 'image/gif':
|
||||||
'video/webm': 'webm',
|
return 'gif'
|
||||||
|
case 'application/pdf':
|
||||||
|
return 'pdf'
|
||||||
|
case 'application/vnd.adobe.flash.movie':
|
||||||
|
return 'swf'
|
||||||
|
case 'video/webm':
|
||||||
|
return 'webm'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -200,7 +283,8 @@ var QR = {
|
|||||||
open() {
|
open() {
|
||||||
if (QR.nodes) {
|
if (QR.nodes) {
|
||||||
if (QR.nodes.el.hidden) {
|
if (QR.nodes.el.hidden) {
|
||||||
QR.captcha.setup()
|
QR.nodes.el.hidden = false
|
||||||
|
QR.unhide()
|
||||||
}
|
}
|
||||||
QR.nodes.el.hidden = false
|
QR.nodes.el.hidden = false
|
||||||
QR.unhide()
|
QR.unhide()
|
||||||
@ -944,8 +1028,7 @@ var QR = {
|
|||||||
QR.abort()
|
QR.abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
$.forceSync()
|
||||||
$.forceSync('cooldowns')
|
|
||||||
if (QR.cooldown.seconds) {
|
if (QR.cooldown.seconds) {
|
||||||
if (force) {
|
if (force) {
|
||||||
QR.cooldown.clear()
|
QR.cooldown.clear()
|
||||||
@ -988,7 +1071,7 @@ var QR = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
QR.captcha.isEnabled &&
|
QR.captcha &&
|
||||||
!(QR.captcha === Captcha.v2 && /\b_ct=/.test(d.cookie) && threadID) &&
|
!(QR.captcha === Captcha.v2 && /\b_ct=/.test(d.cookie) && threadID) &&
|
||||||
!(err && !force)
|
!(err && !force)
|
||||||
) {
|
) {
|
||||||
@ -1000,9 +1083,7 @@ var QR = {
|
|||||||
}
|
}
|
||||||
if (!captcha) {
|
if (!captcha) {
|
||||||
err = 'No valid captcha.'
|
err = 'No valid captcha.'
|
||||||
QR.captcha.setup(
|
QR.captcha.setup(!QR.cooldown.auto || d.activeElement === QR.nodes.status, true)
|
||||||
!QR.cooldown.auto || d.activeElement === QR.nodes.status,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1942,6 +2023,22 @@ var QR = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
post: class {
|
post: class {
|
||||||
|
nodes: { el: any; rm: any; spoiler: any; span: any }
|
||||||
|
spoiler: any
|
||||||
|
thread: string | number
|
||||||
|
name: any
|
||||||
|
email: any
|
||||||
|
sub: any
|
||||||
|
flag: any
|
||||||
|
isLocked: boolean
|
||||||
|
file: any
|
||||||
|
com: any
|
||||||
|
quotedText: string
|
||||||
|
errors: any[]
|
||||||
|
filename: any
|
||||||
|
filesize: string
|
||||||
|
pasting: boolean
|
||||||
|
draggable: any
|
||||||
constructor(select) {
|
constructor(select) {
|
||||||
this.select = this.select.bind(this)
|
this.select = this.select.bind(this)
|
||||||
const el = $.el('a', {
|
const el = $.el('a', {
|
||||||
@ -2049,6 +2146,9 @@ var QR = {
|
|||||||
URL.revokeObjectURL(this.URL)
|
URL.revokeObjectURL(this.URL)
|
||||||
return this.dismissErrors()
|
return this.dismissErrors()
|
||||||
}
|
}
|
||||||
|
URL(URL: any) {
|
||||||
|
throw new Error('Method not implemented.')
|
||||||
|
}
|
||||||
|
|
||||||
lock(lock = true) {
|
lock(lock = true) {
|
||||||
this.isLocked = lock
|
this.isLocked = lock
|
||||||
@ -2375,14 +2475,10 @@ var QR = {
|
|||||||
this.nodes.el.dataset.height = height
|
this.nodes.el.dataset.height = height
|
||||||
this.nodes.el.dataset.width = width
|
this.nodes.el.dataset.width = width
|
||||||
if (height > QR.max_height || width > QR.max_width) {
|
if (height > QR.max_height || width > QR.max_width) {
|
||||||
this.fileError(
|
this.fileError(`Image too large (image: ${height}x${width}px, max: ${QR.max_height}x${QR.max_width}px)`, meta.faq + '#image-too-large')
|
||||||
`Image too large (image: ${height}x${width}px, max: ${QR.max_height}x${QR.max_width}px)`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (height < QR.min_height || width < QR.min_width) {
|
if (height < QR.min_height || width < QR.min_width) {
|
||||||
return this.fileError(
|
return this.fileError(`Image too small (image: ${height}x${width}px, min: ${QR.min_height}x${QR.min_width}px)`, meta.faq + '#image-too-small')
|
||||||
`Image too small (image: ${height}x${width}px, min: ${QR.min_height}x${QR.min_width}px)`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const { videoHeight, videoWidth, duration } = el
|
const { videoHeight, videoWidth, duration } = el
|
||||||
@ -2392,24 +2488,18 @@ var QR = {
|
|||||||
const max_height = Math.min(QR.max_height, QR.max_height_video)
|
const max_height = Math.min(QR.max_height, QR.max_height_video)
|
||||||
const max_width = Math.min(QR.max_width, QR.max_width_video)
|
const max_width = Math.min(QR.max_width, QR.max_width_video)
|
||||||
if (videoHeight > max_height || videoWidth > max_width) {
|
if (videoHeight > max_height || videoWidth > max_width) {
|
||||||
this.fileError(
|
this.fileError(`Video too large (video: ${videoHeight}x${videoWidth}px, max: ${max_height}x${max_width}px)`, meta.faq + '#video-too-large')
|
||||||
`Video too large (video: ${videoHeight}x${videoWidth}px, max: ${max_height}x${max_width}px)`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
||||||
this.fileError(
|
this.fileError(`Video too small (video: ${videoHeight}x${videoWidth}px, min: ${QR.min_height}x${QR.min_width}px)`, meta.faq + '#video-too-small')
|
||||||
`Video too small (video: ${videoHeight}x${videoWidth}px, min: ${QR.min_height}x${QR.min_width}px)`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (!isFinite(duration)) {
|
if (!isFinite(duration)) {
|
||||||
this.fileError('Video lacks duration metadata (try remuxing)')
|
this.fileError ('Video has no duration', meta.faq + '#video-has-no-duration')
|
||||||
} else if (duration > QR.max_duration_video) {
|
} else if (duration > QR.max_duration_video) {
|
||||||
this.fileError(
|
this.fileError(`Video too long (video: ${duration}s, max: ${QR.max_duration_video}s)`, meta.faq + '#video-too-long')
|
||||||
`Video too long (video: ${duration}s, max: ${QR.max_duration_video}s)`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (BoardConfig.noAudio(g.BOARD.ID) && $.hasAudio(el)) {
|
if (BoardConfig.noAudio(g.BOARD.ID) && $.hasAudio(el)) {
|
||||||
return this.fileError('Audio not allowed')
|
return this.fileError('Audio not allowed', meta.faq + '#audio-not-allowed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2471,7 +2561,7 @@ var QR = {
|
|||||||
$.rmClass(this.nodes.el, 'has-file')
|
$.rmClass(this.nodes.el, 'has-file')
|
||||||
this.showFileData()
|
this.showFileData()
|
||||||
URL.revokeObjectURL(this.URL)
|
URL.revokeObjectURL(this.URL)
|
||||||
this.dismissErrors((error) => $.hasClass(error, 'file-error'))
|
this.dismissErrors()
|
||||||
return this.preventAutoPost()
|
return this.preventAutoPost()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2536,6 +2626,9 @@ var QR = {
|
|||||||
e.dataTransfer.setDragImage(this, e.clientX - left, e.clientY - top)
|
e.dataTransfer.setDragImage(this, e.clientX - left, e.clientY - top)
|
||||||
return $.addClass(this, 'drag')
|
return $.addClass(this, 'drag')
|
||||||
}
|
}
|
||||||
|
getBoundingClientRect(): { left: any; top: any } {
|
||||||
|
throw new Error('Method not implemented.')
|
||||||
|
}
|
||||||
|
|
||||||
dragEnd() {
|
dragEnd() {
|
||||||
return $.rmClass(this, 'drag')
|
return $.rmClass(this, 'drag')
|
||||||
@ -2570,6 +2663,9 @@ var QR = {
|
|||||||
QR.status()
|
QR.status()
|
||||||
return QR.captcha.updateThread?.()
|
return QR.captcha.updateThread?.()
|
||||||
}
|
}
|
||||||
|
parentNode(arg0: string, parentNode: any) {
|
||||||
|
throw new Error('Method not implemented.')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
export default QR
|
export default QR
|
||||||
@ -7,6 +7,13 @@ import type SWTinyboard from '../site/SW.tinyboard'
|
|||||||
|
|
||||||
// interfaces might be incomplete
|
// interfaces might be incomplete
|
||||||
export interface BoardConfig {
|
export interface BoardConfig {
|
||||||
|
forced_anon: any
|
||||||
|
sjis_tags: any
|
||||||
|
math_tags: any
|
||||||
|
country_flags: any
|
||||||
|
board_flags: any
|
||||||
|
require_subject: any
|
||||||
|
text_only: any
|
||||||
board: string
|
board: string
|
||||||
bump_limit: number
|
bump_limit: number
|
||||||
cooldowns: {
|
cooldowns: {
|
||||||
@ -30,6 +37,7 @@ export interface BoardConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Board {
|
export interface Board {
|
||||||
|
cooldowns(): any
|
||||||
ID: string
|
ID: string
|
||||||
boardID: string
|
boardID: string
|
||||||
siteID: string
|
siteID: string
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import { d } from '../globals/globals';
|
import { d } from '../globals/globals';
|
||||||
|
|
||||||
const $$ = (selector: string, root: HTMLElement | null = d.body): Element[] =>
|
const $$ = (selector: string, root = d.body) => [...Array.from(root.querySelectorAll(selector))];
|
||||||
Array.from(root?.querySelectorAll(selector) ?? []) as Element[];
|
|
||||||
|
|
||||||
export default $$;
|
export default $$;
|
||||||
@ -24,6 +24,9 @@
|
|||||||
"outDir": "builds/test/crx/tsOutput",
|
"outDir": "builds/test/crx/tsOutput",
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"builds/test/tsOutput"
|
"builds/test/tsOutput",
|
||||||
|
"src/meta/*",
|
||||||
|
"./tools/*",
|
||||||
|
"dist/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user