TPB User Comment Search v2.2

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

  1. // ==UserScript==
  2. // @name TPB User Comment Search v2.2
  3. // @authors Alia_Erenel, EDB, Aaron.Walkhouse
  4. // @description Adds a link to user pages to search for their comments via Google
  5. // @include http*://*thepiratebay.se/user/*
  6. // @version 0.0.1.20140718194717
  7. // @namespace https://greasyfork.org/users/3628
  8. // ==/UserScript==
  9.  
  10. // Getting the username
  11. var username = document.title.match( /^(.*)\s\-/ )[1];
  12.  
  13. // Getting the user status (credit to EDB)
  14. var userclass;
  15. userclass = "blank";
  16. if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/vip.gif") != -1) {
  17. userclass = "vip";
  18. }
  19. if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/helper.png") != -1) {
  20. userclass = "helper";
  21. }
  22. if(document.body.innerHTML.indexOf("http://static.thepiratebay.se/img/trusted.png") != -1) {
  23. userclass = "trusted";
  24. }
  25.  
  26. // The Google search query (tweaked by Aaron.Walkhouse)
  27. if(userclass != "blank") {
  28. gquery = "http://www.google.com/search?sitesearch=thepiratebay.se&tbs=rltm:1&filter=0&q=" + userclass + "+" + "%22" + username + "+" + "at%22" + "+" + "CET"
  29. }
  30. else {
  31. gquery = "http://www.google.com/search?sitesearch=thepiratebay.se&tbs=rltm:1&filter=0&q=" + "%22" + username + "+" + "at%22" + "+" + "CET"
  32. }
  33.  
  34. // Inserting Search button into TPB's layout
  35. var gsearch=document.createElement('div');
  36. gsearch.innerHTML="<a target=new href=\"" + gquery + "\"> Search "+ username +"'s comments</a>";
  37. gsearch.style.textAlign='center';
  38. gsearch.style.marginTop = '5px';
  39.  
  40. var gloc = document.getElementById("searchResult");
  41. gloc.parentNode.insertBefore(gsearch, gloc.nextSibling);