@ -38,12 +38,13 @@ export interface ImageProcessor {
}
}
let qp : QueryProcessor ;
let qp : QueryProcessor ;
export let csettings : Parameters < typeof settings [ ' set ' ] > [ 0 ] = initial_settings ;
export let csettings : Parameters < typeof settings [ ' set ' ] > [ 0 ] ;
let processors : ImageProcessor [ ] =
let processors : ImageProcessor [ ] =
[ thirdeye , pomf , pngv3 , jpg , webm , gif ] ;
[ thirdeye , pomf , pngv3 , jpg , webm , gif ] ;
let cappState : Parameters < typeof appState [ ' set ' ] > [ 0 ] ;
let cappState : Parameters < typeof appState [ ' set ' ] > [ 0 ] ;
settings . subscribe ( async b = > {
settings . subscribe ( async b = > {
if ( ! b ) return ;
if ( b . hyd ) {
if ( b . hyd ) {
// transition from disable to enabled
// transition from disable to enabled
if ( b . ak ) {
if ( b . ak ) {
@ -164,6 +165,8 @@ let pendingPosts: { id: number, op: number }[] = [];
// should be equivalent to buildCumFun(signalNewEmbeds, 5000, {trailing: true})
// should be equivalent to buildCumFun(signalNewEmbeds, 5000, {trailing: true})
const signalNewEmbeds = debounce ( async ( ) = > {
const signalNewEmbeds = debounce ( async ( ) = > {
// ensure user explicitely enabled telemetry
// ensure user explicitely enabled telemetry
if ( ! csettings )
return ;
if ( ! csettings . tm )
if ( ! csettings . tm )
return ;
return ;
try {
try {
@ -190,6 +193,8 @@ const signalNewEmbeds = debounce(async () => {
const shouldUseCache = ( ) = > {
const shouldUseCache = ( ) = > {
if ( cappState . isCatalog )
if ( cappState . isCatalog )
return false ;
return false ;
if ( ! csettings )
return false ;
return typeof csettings . cache == "boolean"
return typeof csettings . cache == "boolean"
? csettings . cache
? csettings . cache
: location . hostname . includes ( 'b4k' ) ;
: location . hostname . includes ( 'b4k' ) ;
@ -205,6 +210,8 @@ const processPost = async (post: HTMLDivElement) => {
let res2 : [ EmbeddedFile [ ] , boolean ] [ ] | undefined = undefined ;
let res2 : [ EmbeddedFile [ ] , boolean ] [ ] | undefined = undefined ;
const reportEmbed = ( ) = > {
const reportEmbed = ( ) = > {
if ( ! csettings )
return false ;
if ( csettings . tm ) {
if ( csettings . tm ) {
// dont report results from archive, only live threads
// dont report results from archive, only live threads
if ( [ 'boards.4chan.org' , 'boards.4channel.org' ] . includes ( location . host ) ) {
if ( [ 'boards.4chan.org' , 'boards.4channel.org' ] . includes ( location . host ) ) {
@ -261,6 +268,8 @@ function copyTextToClipboard(text: string) {
}
}
const scrapeBoard = async ( self : HTMLButtonElement ) = > {
const scrapeBoard = async ( self : HTMLButtonElement ) = > {
if ( ! csettings )
return false ;
if ( csettings . tm ) {
if ( csettings . tm ) {
fireNotification ( "success" , "Scrapping board with telemetry on! Thank you for your service, selfless stranger ;_;7" ) ;
fireNotification ( "success" , "Scrapping board with telemetry on! Thank you for your service, selfless stranger ;_;7" ) ;
}
}
@ -451,6 +460,16 @@ const startup = async (is4chanX = true) => {
else
else
qp = lqp ;
qp = lqp ;
await new Promise < void > ( _ = > {
settings . subscribe ( val = > {
if ( val )
_ ( ) ;
} ) ;
} ) ;
if ( ! csettings )
return false ;
if ( csettings . vercheck )
if ( csettings . vercheck )
versionCheck ( ) ;
versionCheck ( ) ;
@ -513,6 +532,8 @@ const startup = async (is4chanX = true) => {
rec . addedNodes . forEach ( e = > {
rec . addedNodes . forEach ( e = > {
if ( ! ( e instanceof HTMLElement ) )
if ( ! ( e instanceof HTMLElement ) )
return ;
return ;
if ( ! csettings )
return false ;
if ( cappState . isCatalog && csettings . notcata )
if ( cappState . isCatalog && csettings . notcata )
return ;
return ;
// apparently querySelector cannot select the root element if it matches
// apparently querySelector cannot select the root element if it matches
@ -528,7 +549,7 @@ const startup = async (is4chanX = true) => {
mo . observe ( e ! , { childList : true , subtree : true } ) ;
mo . observe ( e ! , { childList : true , subtree : true } ) ;
} ) ;
} ) ;
}
}
if ( ! document . body ) {
if ( ! document . body ) {
let bodyRes : any ;
let bodyRes : any ;
const bodyInit = new Promise ( r = > bodyRes = r ) ;
const bodyInit = new Promise ( r = > bodyRes = r ) ;