Amazon Fake Review Analyzer (ReviewMeta)

It returns ReviewMeta.com percentage of potentially fake reviews on amazon and it recalculates the "true" star score excluding "fake" reviews

  1. // ==UserScript==
  2. // @name Amazon Fake Review Analyzer (ReviewMeta)
  3. // @description It returns ReviewMeta.com percentage of potentially fake reviews on amazon and it recalculates the "true" star score excluding "fake" reviews
  4. // @match https://www.amazon.it/*
  5. // @match https://www.amazon.de/*
  6. // @match https://www.amazon.co.uk/*
  7. // @match https://www.amazon.fr/*
  8. // @match https://www.amazon.es/*
  9. // @match https://www.amazon.com/*
  10. // @version 1.2.1
  11. // @author SH3LL
  12. // @grant GM_xmlhttpRequest
  13. // @namespace https://greasyfork.org/users/762057
  14. // ==/UserScript==
  15.  
  16.  
  17. function get_stars_number(url) {
  18. return new Promise(function (resolve, reject) {
  19. GM_xmlhttpRequest({
  20. method: 'GET',
  21. responseType: 'document',
  22. synchronous: false,
  23. url: url,
  24. onload: (resp) => {
  25. const doc = document.implementation.createHTMLDocument().documentElement;
  26. doc.innerHTML = resp.responseText;
  27. let stars_number = doc.querySelector('#adjusted-rating-large');
  28. let percent = doc.getElementsByTagName('small');
  29. let missing_reviews = doc.getElementsByTagName('center');
  30. if(stars_number !== null) {
  31. stars_number=stars_number.innerText;
  32. for(let perc of percent){
  33. if(perc.innerText.includes("of potentially unnatural reviews removed")){
  34. percent=perc.children[0].children[0].innerText;
  35. break;
  36. }
  37. }
  38. }
  39. resolve([stars_number,percent]);
  40. }
  41. });
  42. });
  43. }
  44.  
  45. async function main(){
  46. let location="it";
  47. if(window.location.href.includes(".it")){location="it";}
  48. if(window.location.href.includes(".de")){location="de";}
  49. if(window.location.href.includes(".fr")){location="fr";}
  50. if(window.location.href.includes(".es")){location="es";}
  51. if(window.location.href.includes(".co.uk")){location="uk";}
  52. if(window.location.href.includes(".com")){location="us";}
  53. if(window.location.href.includes("/dp/") || window.location.href.includes("/gp/product/") ){
  54. let amz_code; //get amazon product code
  55. if(window.location.href.includes("/gp/product/") && window.location.href.includes("?") ){
  56. amz_code=(window.location.href).split("?")[0].split('/gp/product/')[1];
  57. }else if(window.location.href.includes("/gp/product/") && !window.location.href.includes("?")){
  58. amz_code=(window.location.href).split('/gp/product/')[1];
  59.  
  60. }else if(window.location.href.includes("/dp/") && window.location.href.includes("?")){
  61. amz_code=(window.location.href).split("?")[0].split('/dp/')[1].split('/')[0];
  62. }else if(window.location.href.includes("/dp/") && !window.location.href.includes("?")){
  63. amz_code=(window.location.href).split('/dp/')[1].split('/')[0];
  64. }
  65. let rev_url;
  66. if(location==="us" /*america (.com)*/ ) {rev_url="https://reviewmeta.com/amazon/";} else {rev_url="https://reviewmeta.com/amazon-"+location+"/";}
  67. rev_url=rev_url+amz_code;
  68. let stars_number_and_percent = await get_stars_number(rev_url); // get data from ReviewMeta
  69. let stars_block = document.getElementsByClassName('a-fixed-left-grid AverageCustomerReviews a-spacing-small');
  70. if(stars_number_and_percent[0]!==null) {// dati trovati nel database
  71. let message_review = document.createElement('small'); //review info
  72. let message_percent = document.createElement('small'); //review info
  73. let review_value = document.createElement('label'); //review info
  74. let percent_value = document.createElement('label'); //review info
  75. let link_reviewmeta = document.createElement('a'); //link to ReviewMeta
  76. message_review.innerText="ReviewMeta Filtered Reviews "+"["+location.toUpperCase()+"]: ";
  77. message_review.style.color = 'darkorange';
  78. review_value.innerText=stars_number_and_percent[0]+"/5";
  79. review_value.style.color = 'firebrick';
  80. message_percent.innerText="Potentially Fake Reviews ["+location.toUpperCase()+"]: ";
  81. message_percent.style.color = 'darkorange';
  82. percent_value.innerText=stars_number_and_percent[1];
  83. percent_value.style.color = 'firebrick';
  84. message_percent.append(percent_value);
  85. link_reviewmeta.innerText="[Open this product in ReviewMeta]";
  86. link_reviewmeta.style.color = 'forestgreen';
  87. link_reviewmeta.href = rev_url;
  88. let div1 = document.createElement("div");
  89. let div2 = document.createElement("div");
  90. let div3 = document.createElement("div");
  91. div1.append(message_review);
  92. div1.append(review_value);
  93. div2.append(message_percent);
  94. div2.append(percent_value);
  95. div3.append(link_reviewmeta);
  96. stars_block[0].append(div1);
  97. stars_block[0].append(div2);
  98. stars_block[0].append(div3);
  99. }else{ //dati non trovati nel database
  100. let message_review = document.createElement('small'); //review info
  101. let link_reviewmeta = document.createElement('a'); //link to ReviewMeta
  102. message_review.innerText="Missing product in ReviewMeta DataBase-"+location.toUpperCase()+" or missing reviews for Amazon-"+location.toUpperCase();
  103. message_review.style.color = 'firebrick';
  104. link_reviewmeta.innerText="[Add this product to Database]";
  105. link_reviewmeta.style.color = 'forestgreen';
  106. link_reviewmeta.href = rev_url;
  107. let div1 = document.createElement("div");
  108. let div2 = document.createElement("div");
  109. div1.append(message_review);
  110. div2.append(link_reviewmeta);
  111. stars_block[0].append(div1);
  112. stars_block[0].append(div2);
  113. }
  114. }
  115. }
  116.  
  117. main();