Ai text detector

Check if the selected text is written with an AI using the zerogpt API

  1. // ==UserScript==
  2. // @name Ai text detector
  3. // @namespace jpechg@gmail.com
  4. // @version 1
  5. // @description Check if the selected text is written with an AI using the zerogpt API
  6. // @include *
  7. // @grant GM_xmlhttpRequest
  8. // @license GPLv3
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. document.onmouseup = function() {
  15. var text = getSelectionText();
  16. if (text) {
  17. sendPostRequest(text);
  18. }
  19. };
  20.  
  21. function getSelectionText() {
  22. var text = "";
  23. if (window.getSelection) {
  24. text = window.getSelection().toString();
  25. } else if (document.selection && document.selection.type != "Control") {
  26. text = document.selection.createRange().text;
  27. }
  28. return text;
  29. }
  30.  
  31. function sendPostRequest(text) {
  32. var data = {
  33. "input_text": text
  34. };
  35. console.log("Sending POST request with data:", data);
  36. GM_xmlhttpRequest({
  37. method: "POST",
  38. url: "https://api.zerogpt.com/api/detect/detectText",
  39. headers: {
  40. "Host": "api.zerogpt.com",
  41. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
  42. "Accept": "application/json, text/plain, */*",
  43. "Accept-Language": "en-US,en;q=0.5",
  44. "Accept-Encoding": "gzip, deflate, br",
  45. "Content-Type": "application/json",
  46. "Origin": "https://www.zerogpt.com",
  47. "DNT": "1",
  48. "Connection": "keep-alive",
  49. "Referer": "https://www.zerogpt.com/",
  50. "Sec-Fetch-Dest": "empty",
  51. "Sec-Fetch-Mode": "cors",
  52. "Sec-Fetch-Site": "same-site",
  53. "Sec-GPC": "1",
  54. "TE": "trailers"
  55. },
  56. data: JSON.stringify(data),
  57. onload: function(response) {
  58. var res = JSON.parse(response.responseText);
  59. console.log("POST request response:", res);
  60. if (res.success==true){
  61. simulateNotification("The selected text has a " + res.data.fakePercentage + "% chance of being generated by an AI");
  62. }
  63. }
  64. });
  65. }
  66. function simulateNotification(title, message) {
  67. var notificationContainer = document.createElement("div");
  68. notificationContainer.style.cssText = `position: fixed;
  69. top: 10px;
  70. right: 10px;
  71. background-color: #282828; /* Background color for Gruvbox palette */
  72. color: #ebdbb2; /* Text color for Gruvbox palette */
  73. border: 1px solid #3c3836; /* Border color for Gruvbox palette */
  74. padding: 10px;
  75. box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  76. z-index: 9999;
  77. opacity: 1;
  78. transition: opacity 1s, border-radius 0.5s;
  79. border-radius: 5px; /* Rounded corners */";
  80. `
  81. var notificationTitle = document.createElement("div");
  82. notificationTitle.textContent = title;
  83. notificationTitle.style.fontWeight = "bold";
  84.  
  85. var notificationMessage = document.createElement("div");
  86. notificationMessage.textContent = message;
  87.  
  88. notificationContainer.appendChild(notificationTitle);
  89. notificationContainer.appendChild(notificationMessage);
  90. document.body.appendChild(notificationContainer);
  91.  
  92. // Set a timer to fade out the notification after 5 seconds
  93. setTimeout(function() {
  94. notificationContainer.style.opacity = 0;
  95. setTimeout(function() {
  96. document.body.removeChild(notificationContainer);
  97. }, 500); // Remove the notification after the fade-out animation (adjust as needed)
  98. }, 3000); // Start the fade-out animation after 5 seconds (adjust as needed)
  99. }
  100. })();