Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to use mc as a search shortcut for metacritic.com from Google Chrome. I set up the following search URL for the shortcut:

http://metacritic.com/search/all/%s/results

Unfortunately, when I search for patrician iii as follows

mc patrcian iii

Chrome produces this query, which metacritic misinterprets to produce a useless set of unrelated results:

http://www.metacritic.com/search/all/patrician%20iii/results

Metacritic likes this query, giving me exactly the result I was looking for:

http://www.metacritic.com/search/all/patrician+iii/results

How can I force Chrome to use plus symbols instead of URL encoded spaces?

share|improve this question
    
(IE allows you to choose the escape character used for several different ones. Chrome devs however know better than users. :-|) –  Synetech May 13 '11 at 18:18

6 Answers 6

up vote 4 down vote accepted

Though a bit crude, you can create a simple Chrome extensions that adjusts the URL for metacritic (or other sites if you want)

Here's the code I've used for a Metacritic Search URL Replace extension:

manifest.json:

{
    "content_scripts": [ {
    "include_globs": [ "http://www.metacritic.com/search/*%20*" ],
    "js": [ "script.js" ],
        "matches": [ "http://*/*", "https://*/*" ],
        "run_at": "document_start"
    } ],
    "converted_from_user_script": true,
    "description": "Replaces '%20' in metacritic search request to '+'",
    "name": "Metacritic search replacer",
    "version": "0.1"
}

script.js:

window.location = window.location.href.replace(/%20/g, "+");

Since I don't really have a reliable spot to upload my extension, here are the instructions to create a Chrome extension using these two files:

First, put the two files in a folder somehwere and browse to chrome://extensions. Make sure the developer mode is active (look at the top right of the page to enable this). Here you can select 'Pack extension..' which asks you for the folder where your script resides. Once you have selected this folder, the extension will be created and you can just drag & drop it into Chrome to install. If everything went according to plan, the script will rewrite the URL for a Metacritic search request from the '%20' to the '+' characters.

Now, you can use http://metacritic.com/search/all/%s/results as a search engine url in Chrome itself to use a shortcut to this search.

Hope this helps.. ;)

share|improve this answer
    
This actually looks nice. You could upload it to GitHub or something. –  slhck Jun 25 '11 at 21:07
    
Here's the extension (.crx) and source: link –  JiriB Jun 27 '11 at 19:49

You don't need to use the REST style of searching, but can instead use normal HTTP GET parameters like this:

http://www.metacritic.com/search/all/results?search_term=test+query

So in your case that would be:

http://www.metacritic.com/search/all/results?search_term=%s

Unfortunately, this doesn't work with Metacricic (?).

The best I could get is the following search function, however it doesn't really redirect for some reason:

data:text/html;charset=utf-8,<script>var s = "%s"; s = s.replace("%20", "+"); var url = "http://www.metacritic.com/search/all/" + s + "/results"; window.location = url;</script>

Background info:

Chrome encodes the sent parameters depending on the position, i.e. if its within an URL or as a GET parameter. Within an URL it makes sense to convert a space to %20, whereas in a parameter the + is used.

Unfortunately, they're not up to changing this behavior, so my guess would be that a simple line of Javascript could fix this. I'll look into it.

share|improve this answer
    
Did you try it? Doesn't work for patrician iii. –  sheldonh May 11 '11 at 8:02
    
A lot of systems actually use HTTP rewrite to map path names to HTTP GET requests. –  Majenko May 11 '11 at 8:50
    
@sheldonh That's interesting because the search term is correctly inserted, I'll look into it. –  slhck May 11 '11 at 9:11
    
@slhck Yeah, what you're doing really -should- work. Thanks for your time and attention. –  sheldonh May 11 '11 at 9:13
    
@sheldonh I found a method and edited my post, unfortunately Chrome doesn't redirect yet, but we're a step further towards a solution. –  slhck May 11 '11 at 10:29

As pointed out by slhck in his answer, Chrome only supports %s, and insists on "intelligently" determining whether to use plus symbols or %20 to escape spaces (see Chromium bug 78429).

The particular test case I'm dealing with (metacritic.com) imposes too many hoops to leap through concurrently with their RESTful search interface.

Therefore, as a work-around, I elected to simply use app.metacritic.com's legacy interface:

http://apps.metacritic.com/search/process?tfs=game_title&sb=0&game_platform=PC&­ts=%s

If that hadn't been available, I would have contacted metacritic.com, referred them to the Chromium bug, and begged for mercy. :-)

share|improve this answer
    
Apparently this has stopped working. :-( –  A. Donda Nov 1 '13 at 10:56

I couldn't get neither the .crx or the .js to install properly (maybe it is my fault).

I managed to get it working by relying on a greasemonkey script (I do personnaly use the Tampermonkey google chrome extension to handle greasemonkey scripts).

Once in Tampermonkey I create a new script and paste the following (and it works! once again, a BIG THANKS to JiriB, as I just copy/pasted his findings):

// ==UserScript==
// @name         Google-Chrome-URL-Replacer-Extension (Metacritic)
// @namespace    https://github.com/FjearJiri/Google-Chrome-URL-Replacer-Extension/
// @version      1.0
// @description  Replaces %20 with + in URLs in order to build valid URLS for search engine shortcuts
// @include      http://www.metacritic.com/search/*%20*
// @copyright    2011+, FjearJiri ('ported' to greasemonkey script by zifnab)
// ==/UserScript==
// http://superuser.com/questions/281934/forcing-s-to-escape-spaces-with-plus-instead-of-percent-twenty
window.location = window.location.href.replace(/%20/g, "+");
share|improve this answer

I was having difficulty with this same thing, and found this page. Unfortunately the answers were either too complex or, like the legacy search idea, didn't work, and then I suddenly remembered what I used to do with metacritic, which was to search it with google because metacritics search engine was so poor (still is, actually). So what I did was create a google search and make that my metacritic search:

https://www.google.com/search?gcx=w&ix=c2&sourceid=chrome&ie=UTF-8&q=site%3Ametacritic.com+%s

Obviously it's not ideal, in that you don't get metacritic's nice search result page, but it does give useful results. I also created channel specific versions; for example, if I want to search for TV shows I use the same engine with "/tv/" added to it.

share|improve this answer

Edit: I've added this basic extension to the Chrome Store, I also added icons but didn't otherwise change the code. Yay now Chrome can just do its thing and I can delete it from my download folder! Link is: Metacritic search fixer.

Original post: I've updated JiriB's extension code so it works in Chrome again! It really just needed one extra line. I've never used github before, but I forked his project and submitted a pull request.

manifest.json:

{
"content_scripts": [ {
"include_globs": [ "http://www.metacritic.com/search/*%20*" ],
"js": [ "script.js" ],
    "matches": [ "http://*/*", "https://*/*" ],
    "run_at": "document_start"
} ],
"converted_from_user_script": true,
"description": "Replaces '%20' in metacritic search request to '+'",
"name": "Metacritic search fixer",
"manifest_version": 2,
"version": "0.2.2"
}

script.js:

window.location = window.location.href.replace(/%20/g, "+");
share|improve this answer
    
+1 for submitting a pull request! :-) –  sheldonh Aug 1 '13 at 6:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.