GetTokenForKIPAPP

Kirim Token

  1. // ==UserScript==
  2. // @name GetTokenForKIPAPP
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Kirim Token
  6. // @author Anda
  7. // @match https://webapps.bps.go.id/kipapp/*
  8. // @grant GM_xmlhttpRequest
  9. // @require https://cdn.jsdelivr.net/npm/localstorage-slim@2.7.1/dist/localstorage-slim.js
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. let button = document.createElement("button");
  18. button.innerText = "Kirim Token";
  19. button.style.position = "fixed";
  20. button.style.bottom = "20px";
  21. button.style.right = "20px";
  22. button.style.zIndex = "1000";
  23. button.style.padding = "10px 15px";
  24. button.style.backgroundColor = "#28a745";
  25. button.style.color = "white";
  26. button.style.border = "none";
  27. button.style.borderRadius = "5px";
  28. button.style.cursor = "pointer";
  29.  
  30. document.body.appendChild(button);
  31.  
  32. let data;
  33. function waitForLS(callback) {
  34. if (typeof ls !== "undefined") {
  35. callback();
  36. } else {
  37. setTimeout(() => waitForLS(callback), 100);
  38. }
  39. }
  40.  
  41. waitForLS(() => {
  42. console.debug("localstorage-slim tersedia!");
  43.  
  44. // data = localStorage.getItem('ka-p-fa0de6036011042cc37f296a888475a2');
  45. //console.debug(data);
  46. data = ls.get('ka-p-fa0de6036011042cc37f296a888475a2', {decrypt: true, secret: 2188321});
  47. // console.debug(ls.get('ka-p-fa0de6036011042cc37f296a888475a2', {decrypt: true, secret: 2188321}));
  48.  
  49. });
  50.  
  51. function sendDataToForm() {
  52. GM_xmlhttpRequest({
  53. method: "POST",
  54. url: "http://203.194.113.246:88/token", // Ubah URL jika diperlukan
  55. headers: { "Content-Type": "application/x-www-form-urlencoded" },
  56. data: "textarea_input=" + encodeURIComponent(data), // Format x-www-form-urlencoded
  57. onload: function(response) {
  58. if (response.status === 200) {
  59. alert("Token berhasil dikirim");
  60. console.log("Response:", response.responseText);
  61. } else {
  62. alert("Gagal mengirim Token! Status: " + response.status);
  63. }
  64. },
  65. onerror: function(error) {
  66. alert("Terjadi kesalahan saat mengirim data!");
  67. console.error("Error:", error);
  68. }
  69. });
  70. }
  71.  
  72. button.addEventListener("click", function() {
  73. sendDataToForm(); // Kirim data ketika tombol diklik
  74. });
  75.  
  76. })();