Search Selected text on Amazon .com

Im Mahi, and this script helps people to select and seacrh a product by name without having to download any new Search extension, with single click | Saves lot of time for e-commerce employees.

  1. // ==UserScript==
  2. // @description Im Mahi, and this script helps people to select and seacrh a product by name without having to download any new Search extension, with single click | Saves lot of time for e-commerce employees.
  3. // @name Search Selected text on Amazon .com
  4. // @copyright Mahi Balan M | RCA | VBI
  5. // @version 1.23
  6. // @website https://phonetool.amazon.com/users/mahibala
  7. // @namespace *
  8. // @include *
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
  10. // @author Mahi Balan M
  11. // ==/UserScript==
  12. // ==/UserScript==
  13. $(document).ready(function(){
  14. $("body").mouseup(function(e){
  15. // get selected text
  16. var seltext = getSelectedText();
  17. if(seltext != "")
  18. {
  19. if($(".searchit").attr("class") == null)
  20. {
  21. $("<a></a>").appendTo("body")
  22. .attr("title","Search Product on Amazon.com | MB")
  23. .attr("class","searchit")
  24. .css("width","24px")
  25. .css("height","24px")
  26. .css("background-image","url(http://lh4.ggpht.com/_9NnLYMRJob8/TQ9GrnFaweI/AAAAAAAAAVc/f4UtNPKEMUU/find.png)")
  27. .css("display","inline")
  28. .css("background-position","0px 0px")
  29. .attr("href","https://www.amazon.com/s?ie=UTF8&field-keywords="+seltext)
  30. .attr("target","_blank")
  31. .css("left",e.pageX - 5)
  32. .css("top",e.pageY - 30)
  33. .css("display","block")
  34. .css("position","absolute")
  35. .hide()
  36. .fadeIn(0.1);
  37. }
  38. else{
  39. $(".searchit").animate({"left": e.pageX - 2,"top" : e.pageY - 30}, 0.1)
  40. .attr("href","https://www.amazon.com/s?ie=UTF8&field-keywords="+seltext).fadeIn(0.1);
  41. }
  42. }
  43. else
  44. $(".searchit").fadeOut("very very fast");
  45. });
  46. $(".searchit").mouseover(function(){
  47. alert("asa");
  48. });
  49. });
  50. function getSelectedText()
  51. {
  52. // For Firefox
  53. if(window.getSelection)
  54. return window.getSelection();
  55. else if(document.getSelection)
  56. return document.getSelection();
  57. else
  58. {
  59. // For IE
  60. var selection = document.selection && document.selection.createRange();
  61. if(selection.text)
  62. return selection.text;
  63. return false;
  64. }
  65. return false;
  66. }