mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2026-01-30 09:48:12 +01:00
types
This commit is contained in:
parent
7cb3ec8b6e
commit
aaa196e3b7
@ -79,7 +79,7 @@ const ImageCommon = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const threadJSON = g.SITE.urls.threadJSON?.(post)
|
const threadJSON = g.SITE.urls.threadJSON?.(post, fileObj)
|
||||||
if (!threadJSON) { return }
|
if (!threadJSON) { return }
|
||||||
const parseJSON = function (isArchiveURL) {
|
const parseJSON = function (isArchiveURL) {
|
||||||
let needle, postObj
|
let needle, postObj
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import CaptchaT from "./Captcha.t"
|
|||||||
import QR from "./QR"
|
import QR from "./QR"
|
||||||
|
|
||||||
const Captcha = {
|
const Captcha = {
|
||||||
|
replace: CaptchaReplace,
|
||||||
cache: {
|
cache: {
|
||||||
init() {
|
init() {
|
||||||
$.on(d, 'SaveCaptcha', e => {
|
$.on(d, 'SaveCaptcha', e => {
|
||||||
|
|||||||
@ -80,7 +80,12 @@ const Quotify = {
|
|||||||
// Don't (Dead) when quotifying in an archived post,
|
// Don't (Dead) when quotifying in an archived post,
|
||||||
// and we know the post still exists.
|
// and we know the post still exists.
|
||||||
a = $.el('a', {
|
a = $.el('a', {
|
||||||
href: g.SITE.Build.postURL(boardID, post.thread.ID, postID),
|
href: g.SITE.Build.postURL({
|
||||||
|
siteID: boardID,
|
||||||
|
boardID,
|
||||||
|
threadID: post.thread.ID,
|
||||||
|
postID
|
||||||
|
}),
|
||||||
className: 'quotelink',
|
className: 'quotelink',
|
||||||
textContent: quote
|
textContent: quote
|
||||||
}
|
}
|
||||||
@ -88,12 +93,17 @@ const Quotify = {
|
|||||||
} else {
|
} else {
|
||||||
// Replace the .deadlink span if we can redirect.
|
// Replace the .deadlink span if we can redirect.
|
||||||
a = $.el('a', {
|
a = $.el('a', {
|
||||||
href: g.SITE.Build.postURL(boardID, post.thread.ID, postID),
|
href: g.SITE.Build.postURL({
|
||||||
|
siteID: boardID,
|
||||||
|
boardID,
|
||||||
|
threadID: 0,
|
||||||
|
postID
|
||||||
|
}),
|
||||||
className: 'quotelink deadlink',
|
className: 'quotelink deadlink',
|
||||||
textContent: quote
|
textContent: quote
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
$.add(a, Post.deadMark.cloneNode(true))
|
$.add(a, Post.deadMark.cloneNode(true) as Element)
|
||||||
$.extend(a.dataset, { boardID, threadID: post.thread.ID, postID })
|
$.extend(a.dataset, { boardID, threadID: post.thread.ID, postID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +118,7 @@ const Quotify = {
|
|||||||
textContent: quote
|
textContent: quote
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
$.add(a, Post.deadMark.cloneNode(true))
|
$.add(a, Post.deadMark.cloneNode(true) as Element)
|
||||||
if (fetchable) {
|
if (fetchable) {
|
||||||
// Make it function as a normal quote if we can fetch the post.
|
// Make it function as a normal quote if we can fetch the post.
|
||||||
$.addClass(a, 'quotelink')
|
$.addClass(a, 'quotelink')
|
||||||
@ -120,7 +130,7 @@ const Quotify = {
|
|||||||
if (!this.quotes.includes(quoteID)) { this.quotes.push(quoteID) }
|
if (!this.quotes.includes(quoteID)) { this.quotes.push(quoteID) }
|
||||||
|
|
||||||
if (!a) {
|
if (!a) {
|
||||||
$.add(deadlink, Post.deadMark.cloneNode(true))
|
$.add(deadlink, Post.deadMark.cloneNode(true) as Element)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +148,11 @@ const Quotify = {
|
|||||||
$.before(deadlink, green)
|
$.before(deadlink, green)
|
||||||
$.add(green, deadlink)
|
$.add(green, deadlink)
|
||||||
}
|
}
|
||||||
return $.replace(deadlink, [...Array.from(deadlink.childNodes)])
|
return $.replace(deadlink, $.el('span', {
|
||||||
|
className: 'deadlink',
|
||||||
|
textContent: deadlink.textContent
|
||||||
|
}
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default Quotify
|
export default Quotify
|
||||||
|
|||||||
@ -7,9 +7,16 @@ export default class CatalogThread {
|
|||||||
ID: string | number
|
ID: string | number
|
||||||
thread: Thread
|
thread: Thread
|
||||||
board: Board
|
board: Board
|
||||||
nodes: { root: Post; thumb: HTMLElement; icons: any; postCount: number; fileCount: number; pageCount: number; replies: any }
|
nodes: {
|
||||||
|
root: Post,
|
||||||
|
thumb: Element,
|
||||||
|
icons: Element,
|
||||||
|
postCount: Element,
|
||||||
|
fileCount: Element,
|
||||||
|
pageCount: Element,
|
||||||
|
replies: Element
|
||||||
|
}
|
||||||
toString() { return this.ID }
|
toString() { return this.ID }
|
||||||
|
|
||||||
constructor(root: Post, thread: Thread) {
|
constructor(root: Post, thread: Thread) {
|
||||||
this.thread = thread
|
this.thread = thread
|
||||||
this.ID = this.thread.ID + ''
|
this.ID = this.thread.ID + ''
|
||||||
|
|||||||
@ -10,6 +10,7 @@ declare global {
|
|||||||
wrappedJSObject: any
|
wrappedJSObject: any
|
||||||
Tegaki: any
|
Tegaki: any
|
||||||
FCX: any
|
FCX: any
|
||||||
|
Parser: any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// interfaces might be incomplete
|
// interfaces might be incomplete
|
||||||
|
|||||||
@ -74,7 +74,6 @@ const SWTinyboard = {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
ID: 'sw-tinyboard',
|
|
||||||
parseThreadMetadata(el: HTMLElement) {
|
parseThreadMetadata(el: HTMLElement) {
|
||||||
const thread = dict()
|
const thread = dict()
|
||||||
const op = el.querySelector('.op')
|
const op = el.querySelector('.op')
|
||||||
@ -219,6 +218,9 @@ $\
|
|||||||
},
|
},
|
||||||
|
|
||||||
Build: {
|
Build: {
|
||||||
|
postURL({ siteID, boardID, threadID, postID }) {
|
||||||
|
return `${Conf['siteProperties'][siteID]?.root || `http://${siteID}/`}${boardID}/res/${threadID}.html#${postID}`
|
||||||
|
},
|
||||||
parseJSON(data, board) {
|
parseJSON(data, board) {
|
||||||
const o = this.parseJSON(data, board)
|
const o = this.parseJSON(data, board)
|
||||||
if (data.ext === 'deleted') {
|
if (data.ext === 'deleted') {
|
||||||
@ -315,7 +317,7 @@ $\
|
|||||||
if (!(info = infoNode.textContent.match(/\((.*,\s*)?([\d.]+ ?[KMG]?B).*\)/))) { return false }
|
if (!(info = infoNode.textContent.match(/\((.*,\s*)?([\d.]+ ?[KMG]?B).*\)/))) { return false }
|
||||||
const nameNode = $('.postfilename', text)
|
const nameNode = $('.postfilename', text)
|
||||||
$.extend(file, {
|
$.extend(file, {
|
||||||
name: nameNode ? (nameNode.title || nameNode.textContent) : link.pathname.match(/[^/]*$/)[0],
|
name: nameNode ? (nameNode.textContent || '').trim() : '',
|
||||||
size: info[2],
|
size: info[2],
|
||||||
dimensions: info[0].match(/\d+x\d+/)?.[0]
|
dimensions: info[0].match(/\d+x\d+/)?.[0]
|
||||||
})
|
})
|
||||||
|
|||||||
@ -306,11 +306,19 @@ $\
|
|||||||
|
|
||||||
insertTags(bq) {
|
insertTags(bq) {
|
||||||
let node
|
let node
|
||||||
for (node of $$('s, .removed-spoiler', bq)) {
|
const nodes = []
|
||||||
$.replace(node, [$.tn('[spoiler]'), ...Array.from(node.childNodes), $.tn('[/spoiler]')])
|
const {children} = bq
|
||||||
|
for (let i = 0; i < children.length; i++) {
|
||||||
|
if ((node = children[i]) && (node.nodeName === 'A') && (node.textContent === '>>')) {
|
||||||
|
nodes.push(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (node of $$('.prettyprint', bq)) {
|
for (const node of nodes) {
|
||||||
$.replace(node, [$.tn('[code]'), ...Array.from(node.childNodes), $.tn('[/code]')])
|
const {href} = node
|
||||||
|
const {textContent} = node.nextSibling
|
||||||
|
const tag = $.el('a', {href, textContent})
|
||||||
|
$.after(node, tag)
|
||||||
|
$.rm(node)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -342,7 +350,7 @@ $\
|
|||||||
},
|
},
|
||||||
|
|
||||||
transformBoardList() {
|
transformBoardList() {
|
||||||
let node
|
let node = null
|
||||||
const nodes = []
|
const nodes = []
|
||||||
const spacer = () => $.el('span', {className: 'spacer'})
|
const spacer = () => $.el('span', {className: 'spacer'})
|
||||||
const items = $.X('.//a|.//text()[not(ancestor::a)]', $(SWYotsuba.selectors.boardList))
|
const items = $.X('.//a|.//text()[not(ancestor::a)]', $(SWYotsuba.selectors.boardList))
|
||||||
@ -622,7 +630,7 @@ $\
|
|||||||
thread(thread, data, withReplies) {
|
thread(thread, data, withReplies) {
|
||||||
let root
|
let root
|
||||||
if (root = thread.nodes.root) {
|
if (root = thread.nodes.root) {
|
||||||
$.rmAll(root)
|
$.rmAll(root, thread.OP.nodes.root)
|
||||||
} else {
|
} else {
|
||||||
thread.nodes.root = (root = $.el('div', {
|
thread.nodes.root = (root = $.el('div', {
|
||||||
className: 'thread',
|
className: 'thread',
|
||||||
@ -678,7 +686,7 @@ $\
|
|||||||
'div',
|
'div',
|
||||||
generateCatalogThreadHtml(thread, src, imgClass, data, postCount, fileCount, pageCount, staticPath, gifIcon)
|
generateCatalogThreadHtml(thread, src, imgClass, data, postCount, fileCount, pageCount, staticPath, gifIcon)
|
||||||
)
|
)
|
||||||
$.before(thread.OP.nodes.info, [...Array.from(container.childNodes)])
|
$.before(thread.OP.nodes.info, container)
|
||||||
|
|
||||||
for (const br of $$('br', thread.OP.nodes.comment)) {
|
for (const br of $$('br', thread.OP.nodes.comment)) {
|
||||||
if (br.previousSibling && (br.previousSibling.nodeName === 'BR')) {
|
if (br.previousSibling && (br.previousSibling.nodeName === 'BR')) {
|
||||||
@ -691,7 +699,7 @@ $\
|
|||||||
id: `t${thread}`
|
id: `t${thread}`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (thread.OP.highlights) { $.addClass(root, ...Array.from(thread.OP.highlights)) }
|
if (thread.OP.highlights) { $.addClass(root, 'highlight') }
|
||||||
if (!thread.OP.file) { $.addClass(root, 'noFile') }
|
if (!thread.OP.file) { $.addClass(root, 'noFile') }
|
||||||
root.style.cssText = cssText || ''
|
root.style.cssText = cssText || ''
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user