Sploop.io - Translator

Translate a text which any language to English whenever you want!

  1. // ==UserScript==
  2. // @name Sploop.io - Translator
  3. // @namespace Google Translator
  4. // @version 1
  5. // @description Translate a text which any language to English whenever you want!
  6. // @author ilyax
  7. // @match https://sploop.io/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=sploop.io
  9. // @grant none
  10. // @license ilyax 2024 copyright.
  11. // ==/UserScript==
  12.  
  13.  
  14. // Notifications are Forked From Lovey-mod which made by me!
  15. let notifications = [];
  16. function notif(mode, title, description, duration) {
  17. let style = `
  18. position: fixed;
  19. top: ${20 + notifications.length * 60}px;
  20. left: 10px;
  21. padding: 10px 20px;
  22. background-color: #f44336;
  23. color: white;
  24. border-radius: 5px;
  25. border: 10px solid white;
  26. opacity: 1;
  27. width: 20%;
  28. transition: opacity 0.5s ease-in-out;
  29. z-index: 99999999999999999999999999999999999999999999999999;
  30.  
  31. `;
  32. let notification = document.createElement('div');
  33. notification.style = style;
  34. notification.innerHTML = `<h3>${title}</h3><p style="color: white">${description}</p>`;
  35. document.body.appendChild(notification);
  36. var notificationsound;
  37. if (mode == "info") { notificationsound = new Audio('https://cdn.glitch.global/4c998580-5aaf-4a1a-8da3-e0c6b9f241a7/Audio_-_notification3_-_Creator_Store%20(1).mp3') }
  38. else if (mode == "warning") { notificationsound = new Audio('https://cdn.glitch.global/ca081162-612b-4311-8a7d-7828f21c13e0/confirm.mp3?v=1723982480020') }
  39. else if (mode == "error") { notificationsound = new Audio('https://cdn.glitch.global/ca081162-612b-4311-8a7d-7828f21c13e0/48643e6a-f6d2-4462-acdc-2b2d2ccb14fa.beep-02.mp3?v=1724795422902') }
  40. if (mode == "none") return
  41. notificationsound.volume = 0.3;
  42. notificationsound.play();
  43. setTimeout(function() {
  44. notification.style.opacity = '0';
  45. setTimeout(function() {
  46. notification.remove();
  47. notifications.shift();
  48. updateNotificationPositions();
  49. }, 1000);
  50. }, duration);
  51.  
  52. notifications.push(notification);
  53. updateNotificationPositions();
  54. }
  55.  
  56. function updateNotificationPositions() {
  57. notifications.forEach(function(notification, index) {
  58. notification.style.top = `${20 + index * 135}px`;
  59. });
  60. }
  61.  
  62. let handleTranslating = "none"
  63. function translate(text) {
  64. if (text == null || text.trim() == "") {
  65. notif("warning", "Translate Case", "The text that was given is empty, please fill it to translate.", 5000);
  66. handleTranslating = "empty"
  67. return Promise.resolve(""); // Boş metin kontrolü
  68. }
  69.  
  70. return fetch(`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q=${encodeURIComponent(text)}`)
  71. .then(doors => {
  72. if (!doors.ok) {
  73. notif("warning", "Translate Failed", "Sorry but the translation failed due fetch. please report this to ilyax!", 5000);
  74. handleTranslating = "error"
  75. }
  76. return doors.json();
  77. })
  78. .then(translated => {
  79. const ae86 = translated[0][0][0];
  80. return ae86;
  81. })
  82. }
  83.  
  84. document.addEventListener("keydown", event => {
  85. if (event.code === "Numpad1") {
  86. notif("info", "Translate Case", "Trying to translate, Wait a second.", 1000);
  87. let chatmsg = document.getElementById("chat").value;
  88. translate(chatmsg).then(translatedText => {
  89. if (handleTranslating != "empty" || handleTranslating != "error") { // wow!!!!!
  90. notif("info", "Translate Case", "Translated Succesfully!", 1000);
  91. document.getElementById("chat").value = translatedText;
  92. }
  93. });
  94. }
  95. });
  96.  
  97.