URL redirection Google Extension

0

I have a silly problem, but I can not solve it.

Come on:

I want to adapt this code

var pattern=/\bBloqueado/;
var viewtext = "http://www.google.com.br";
var newurl;
if (pattern.test(window.document.title))
{
newurl = viewtext;
chrome.extension.sendRequest({redirect: newurl});

}

He sees if the page title is spelled "Blocked" and is redirected to link

I need something that checks if Url is exactly google.com and if it is redirected to google.com and if google.com stops and does nothing.

Can anyone help me?

    
asked by anonymous 04.03.2015 / 14:06

1 answer

1

I think this helps you:

var padrao = /^(http:\/\/|https:\/\/)?(www\.)?google\.com(\/)?$/g;
var url    = "http://google.com.br/";

if (padrao.test(window.document.location.href)) {
    chrome.extension.sendRequest({redirect:url});
}
    
04.03.2015 / 15:13