Skip to content

Commit

Permalink
fix(ddg): added more-results logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ManagarmrWhisperer committed Jan 14, 2024
1 parent e95191c commit 9e56525
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions js/ddg.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getWikis, getNativeSettings } from './util.js';
import {
prepareWikisInfo,
invokeSearchModule,
awaitElement
} from './baseSearch.js';


Expand Down Expand Up @@ -213,18 +212,23 @@ const rewrite = {

getNativeSettings().local.get( [ 'ddgEnable' ], result => {
if ( result.ddgEnable || result.ddgEnable === undefined ) {
awaitElement(
document.getElementById( 'react-layout' ),
'div > div > section',
sectionNode => {
awaitElement(
sectionNode,
'.react-results--main',
node => {
invokeSearchModule( wikis, rewrite.run.bind( rewrite ), filter.run.bind( filter ), node );
const moreResultsContainer = document.getElementById( 'react-layout' );
const dynamicObserver = new MutationObserver( updates => {
for ( const update of updates ) {
if ( update.addedNodes && update.addedNodes.length > 0 ) {
for ( const addedNode of update.addedNodes ) {
invokeSearchModule( wikis, rewrite.run.bind( rewrite ), filter.run.bind( filter ) );
}
);
}
}
);
} );

dynamicObserver.observe( moreResultsContainer, {
childList: true,
subtree: true
} );

}
} );


0 comments on commit 9e56525

Please sign in to comment.