@@ -562,9 +562,30 @@ var clusterize = new Clusterize({
562562} )
563563
564564// TODO: move to own file?
565+ const isPrismarineDocs = ( url ) => url && url . includes ( 'prismarinejs.github.io/minecraft-data' )
566+
565567async function fillWiki ( ) {
566- let data = ( await axios . get ( sharedVars . proxyCapabilities . wikiVgPage ) ) . data
567- // Allow it to load properly
568+ const wikiUrl = sharedVars . proxyCapabilities . wikiVgPage
569+
570+ if ( isPrismarineDocs ( wikiUrl ) ) {
571+ const iframe = document . getElementById ( 'iframe' )
572+ iframe . src = wikiUrl
573+
574+ const style = document . createElement ( 'style' )
575+ style . id = 'wiki-iframe-style'
576+ style . innerHTML = `
577+ #iframe::-webkit-scrollbar { width: 17px; }
578+ #iframe::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.3); border-radius: 10px; }
579+ #iframe::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); border-radius: 10px; }
580+ #iframe::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.5); }
581+ #iframe::-webkit-scrollbar-corner { background: #242424; }
582+ `
583+ document . head . appendChild ( style )
584+ return
585+ }
586+
587+ // wiki.vg (Java): fetch HTML and inject
588+ let data = ( await axios . get ( wikiUrl ) ) . data
568589 data = data
569590 . split ( '/images/' )
570591 . join ( 'https://wiki.vg/images/' )
@@ -573,7 +594,6 @@ async function fillWiki () {
573594 . split ( '/load.php?' )
574595 . join ( 'https://wiki.vg/load.php?' )
575596
576- // TODO: Break or modify links?
577597 document . getElementById ( 'iframe' ) . contentWindow . document . write ( data )
578598
579599 const style = document . createElement ( 'style' ) ;
@@ -654,13 +674,26 @@ function scrollIdIntoView (id, bound) {
654674}
655675
656676function scrollWikiToCurrentPacket ( ) {
657- if ( currentPacket ) {
658- const packet = sharedVars . allPackets [ currentPacket ]
677+ if ( ! currentPacket ) return
678+ const packet = sharedVars . allPackets [ currentPacket ]
679+ const wikiUrl = sharedVars . proxyCapabilities . wikiVgPage
680+
681+ if ( isPrismarineDocs ( wikiUrl ) ) {
682+ const baseUrl = wikiUrl . split ( '#' ) [ 0 ]
683+ const packetAnchor = 'packet_' + ( packet . meta . name || '' )
684+ const iframe = document . getElementById ( 'iframe' )
659685 try {
660- scrollIdIntoView ( packet . hexIdString , packet . direction )
686+ iframe . contentWindow . location = baseUrl + '#' + packetAnchor
661687 } catch ( err ) {
662- console . error ( err ) ;
688+ console . error ( err )
663689 }
690+ return
691+ }
692+
693+ try {
694+ scrollIdIntoView ( packet . hexIdString , packet . direction )
695+ } catch ( err ) {
696+ console . error ( err )
664697 }
665698}
666699
0 commit comments