User talk:The Transhumanist/StripSearchSimple.js


 * This script is functional

StripSearchSimple.js: strips search results down to bare pagenames. It has no menu item to turn it off – it changes all search results pages. It's an early version of StripSearch.js. For Vector skin only.

= Script's workshop =
 * This is the work area for developing the script, and for presenting its documentation. The talk page portion of this page starts at, below.

Description / instruction manual

 * This script is functional

StripSearchSimple.js: strips search results down to bare pagenames. It has no menu item to turn it off – it changes all search results pages. It's an early version of StripSearch.js. For Vector skin only.

This reduces the search results to a list of links. It strips out the data between the page names, including that annoying "from redirect" note. This makes it easier to copy and paste the links from search results into lists.

Once installed, it automatically reformats all Wikipedia search results.

General approach
The script uses the jQuery method .hide for stripping the elements by class name. Here's an example of stripping out elements with the class name "searchalttitle":

Learn about methods at https://www.w3schools.com/js/js_object_methods.asp

Learn about .hide at http://api.jquery.com/hide/

Activation filters
I didn't know what else to call these. I wanted the program to only work when intended, and only on intended pages (search result pages). So, I applied the conditional, if.

I use the Vector skin, and haven't tested the script on any other skin, so the script basically says "if the vector skin is in use, do what's between the curly brackets". (Which includes the entire rest of the program).

Prep work
There is no prep work in this script. This would be the declaration of global variables and so on.

Core program
This is the part controls the main flow of the script (decides what to do under what circumstances):

So, what this does is 4 things:

First, it checks if the Vector skin is being used and runs the rest of the script only if it is.

Then it applies the jQuery method .hide on all elements labeled as any of these 3 classes: searchalttitle, searchresult, or mw-search-result-data.

To use an object method, you append it to the end of an element, as is done with  3 times above. Don't forget the parentheses, and be sure to end your statements with a semicolon.

Learn more about .hide at http://api.jquery.com/hide/

mw.config.get ( 'skin' )
This looks up the value for skin (the internal name of the currently used skin) saved in MediaWiki's configuration file.


 * jQuery get Method
 * mw.config

logical operators
" " means "equal value and equal type"


 * JavaScript Comparison and Logical Operators

Strip out the sister project results
To write the above, I searched the pagesource for the classes of the data displayed in the right-hand column, traced back to their parent "id="mw-interwiki-results", wrapped that in a jQuery object ("$" means "jQuery"), and then attached the hide method to it.

Change log

 * 2017-09-25
 * Started script
 * Version 1.0 complete
 * Removes lines with page data from the search results
 * Removes content excerpts from the search results
 * Removes "from redirect" comments from the search results
 * Strips out sister project results (from right-hand column)

Desired/completed features

 * Completed features are marked with ✅

Improvements that would be nice:


 * Remove lines with page data from search results ✅
 * Remove content excerpts from search results ✅
 * Remove "from redirect" comments from search results ✅
 * Strip sister project results ✅
 * Remove the drawn lines between the search result entries
 * Remove alternating background colors from behind the search results
 * Reduce spacing between result entries
 * A note at the top of the search column "search results formatted by StripSearch.js", linked to the instruction manual section of the script's workshop page.
 * Remove redirected entries from the search results

Remove lines between the search result entries
The lines seem to be part of the configuration of li, or one of the classes.

Perhaps whichever one it is can be replaced with another element with different formatting.

Add note to search results page
Add a note at the top of the search column "search results formatted by StripSearch.js, linked to the instruction manual section of the script's workshop page.