Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Wikipedia:WikiProject User scripts/Scripts/Search links

From Wikipedia, the free encyclopedia
// <syntaxhighlight lang="javascript">
// Adds toolbox links to search Google web, news archive, books, scholar, and images for the title of the page.

$.when($.ready, mw.loader.using('mediawiki.util')).then(function () {
    if (mw.config.get('wgCanonicalNamespace') === "Special")
        return;  // no links for special pages

    var title = mw.config.get('wgTitle');
    if (mw.config.get('wgCanonicalNamespace') !== "")
        title = title.replace(/^.*\//, "");  // subpage name only

    var query = encodeURIComponent('"'+title+'" -Wikipedia' ); 
    mw.util.addPortletLink('p-tb', 'http://www.google.com/search?&q='+query,
                   'Web search', 't-googlesearch', 'Search Google for "'+title+'"', 'W');
    mw.util.addPortletLink('p-tb', 'http://www.google.com/search?&tbm=nws&tbs=ar:1&q='+query,
                   'News search', 't-googlenewssearch', 'Search Google News Archive for "'+title+'"', 'N');
    mw.util.addPortletLink('p-tb', 'http://books.google.com/books?&as_brr=0&as_pub=-icon&q='+query,
                   'Books search', 't-googlebookssearch', 'Search Google Books for "'+title+'"', 'B');
    mw.util.addPortletLink('p-tb', 'http://scholar.google.com/scholar?&q='+query,
                   'Scholar search', 't-googlescholarsearch', 'Search Google Scholar for "'+title+'"', 'S');
    mw.util.addPortletLink('p-tb', 'http://www.google.com/images?safe=off&tbm=isch&q='+query,
                   'Images search', 't-googleimagesearch', 'Search Google Images for "'+title+'"', 'I');
});

//</syntaxhighlight>