TPB User Comment Search v2.2

Adds a link to user pages to search for their comments via Google

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name          TPB User Comment Search v2.2
// @authors       Alia_Erenel, EDB, Aaron.Walkhouse
// @description   Adds a link to user pages to search for their comments via Google
// @include       http*://*thepiratebay.se/user/*
// @version 0.0.1.20140718194717
// @namespace https://greasyfork.org/users/3628
// ==/UserScript==

// Getting the username
var username = document.title.match( /^(.*)\s\-/ )[1];

// Getting the user status (credit to EDB)
var userclass;
userclass = "blank";
if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/vip.gif") != -1) {
    userclass = "vip";
}
if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/helper.png") != -1) {
    userclass = "helper";
}
if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/trusted.png") != -1) {
    userclass = "trusted";
}

// The Google search query (tweaked by Aaron.Walkhouse)
if(userclass != "blank") {
gquery = "http://www.google.com/search?sitesearch=thepiratebay.se&tbs=rltm:1&filter=0&q=" + userclass + "+" + "%22" + username + "+" + "at%22" + "+" + "CET"
}
else {
gquery = "http://www.google.com/search?sitesearch=thepiratebay.se&tbs=rltm:1&filter=0&q=" + "%22" + username + "+" + "at%22" + "+" + "CET"
}

// Inserting Search button into TPB's layout
var gsearch=document.createElement('div');
  gsearch.innerHTML="<a target=new href=\"" + gquery + "\"> Search "+ username +"'s comments</a>";
  gsearch.style.textAlign='center';
  gsearch.style.marginTop = '5px';      

var gloc = document.getElementById("searchResult");
    gloc.parentNode.insertBefore(gsearch, gloc.nextSibling);