Skip to content

Commit

Permalink
Don't add "Add to AI chat" link if search result doesn't have a snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 7, 2024
1 parent b2e3eda commit 5d1ac32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/ext.askai.search.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* Shows "Add to AI chat" link near every search result on Special:Search. */

$( function () {
const $results = $( '.mw-search-result' );
if ( !$results.length ) {
const $snippets = $( '.searchresult' );
if ( !$snippets.length ) {
return;
}

Expand Down Expand Up @@ -60,8 +60,8 @@ $( function () {
}

// Every result should have "Add to AI chat" link
$results.each( ( idx, result ) => {
$( result ).find( '.mw-search-result-data' ).append( ' ', $( '<a>' )
$snippets.each( ( idx, result ) => {
$( result ).next( '.mw-search-result-data' ).append( ' ', $( '<a>' )
.attr( 'class', 'mw-askai-search-add' )
.append( mw.msg( 'askai-search-add' ) )
.click( addToAI )
Expand Down

0 comments on commit 5d1ac32

Please sign in to comment.