work.ink bypasser

Automatically does work.ink steps.

当前为 2023-05-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name work.ink bypasser
  3. // @namespace lemons
  4. // @match https://work.ink/*
  5. // @match https://workink.click/*
  6. // @match *://*/direct/?*
  7. // @grant none
  8. // @icon https://work.ink/favicon.ico
  9. // @license GPLv3.0-or-later
  10. // @version 1.0.4
  11. // @author lemons
  12. // @description Automatically does work.ink steps.
  13. // @noframes
  14. // ==/UserScript==
  15.  
  16. (async () => {
  17. if (window.location.hostname === "work.ink") {
  18. const websocketUrl = "wss://redirect-api.work.ink/v1/ws";
  19.  
  20. const [encodedUserId, linkCustom] = decodeURIComponent(window.location.pathname.slice(1)).split("/").slice(-2);
  21. const BASE = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  22. const loopTimes = encodedUserId.length;
  23. let decodedUserId = BASE.indexOf(encodedUserId[0]);
  24. for (let i = 1; i < loopTimes; i++) decodedUserId = 62 * decodedUserId + BASE.indexOf(encodedUserId[i]);
  25.  
  26. const payloads = {
  27. announce: JSON.stringify({
  28. type: "c_announce",
  29. payload: {
  30. linkCustom: linkCustom,
  31. linkUserId: decodedUserId,
  32. referer: "unknown",
  33. }
  34. }),
  35. ping: JSON.stringify({
  36. type: "c_ping",
  37. payload: {}
  38. }),
  39. captcha: JSON.stringify({
  40. type: "c_recaptcha_response",
  41. payload: {
  42. "recaptchaResponse": crypto.randomUUID()
  43. }
  44. }),
  45. social: (url) => JSON.stringify({
  46. type: "c_social_started",
  47. payload: {
  48. url
  49. }
  50. }),
  51. readArticles: {
  52. 1: JSON.stringify({
  53. type: "c_monetization",
  54. payload: {
  55. type: "readArticles",
  56. payload: {
  57. event: "start"
  58. }
  59. }
  60. }),
  61. 2: JSON.stringify({
  62. type: "c_monetization",
  63. payload: {
  64. type: "readArticles",
  65. payload: {
  66. event: "closeClicked"
  67. }
  68. }
  69. })
  70. },
  71. browserExtension: {
  72. 1: JSON.stringify({
  73. type: "c_monetization",
  74. payload: {
  75. type: "browserExtension",
  76. payload: {
  77. event: "start"
  78. }
  79. }
  80. }),
  81. 2: (token) => JSON.stringify({
  82. type: "c_monetization",
  83. payload: {
  84. type: "browserExtension",
  85. payload: {
  86. event: "confirm",
  87. token
  88. }
  89. }
  90. })
  91. }
  92. }
  93.  
  94. let ws = new WebSocket(websocketUrl);
  95. ws.onopen = () => {
  96. ws.send(payloads.announce);
  97. };
  98.  
  99. let socials = [];
  100. let activeMonetizationTypes = [];
  101. ws.onmessage = async (e) => {
  102. const sleep = ms => new Promise(r => setTimeout(r, ms));
  103. const data = JSON.parse(e.data);
  104. if (data.error) return;
  105. const payload = data.payload;
  106.  
  107. switch (data.type) {
  108. case "s_link_info":
  109. if (payload.socials) socials.push(...payload.socials);
  110. const monetizationTypes = ["readArticles", "browserExtension"];
  111. for (const type of monetizationTypes) {
  112. if (payload.monetizationScript.includes(type)) {
  113. activeMonetizationTypes.push(type)
  114. }
  115. }
  116. break;
  117. case "s_start_recaptcha_check":
  118. ws.send(payloads.captcha);
  119. break;
  120. case "s_recaptcha_okay":
  121. if (socials.length) {
  122. for (const [index, social] of socials.entries()) {
  123. ws.send(payloads.social(social.url));
  124. await sleep(3 * 1000);
  125. }
  126. }
  127.  
  128. if (activeMonetizationTypes.length) {
  129. for (const type of activeMonetizationTypes) {
  130. switch (type) {
  131. case "readArticles":
  132. ws.send(payloads.readArticles["1"]);
  133. ws.send(payloads.readArticles["2"]);
  134. break;
  135. case "browserExtension":
  136. if (activeMonetizationTypes.includes("readArticles")) await sleep(11 * 1000);
  137. ws.send(payloads.browserExtension["1"])
  138. break;
  139. }
  140. }
  141. }
  142. break;
  143. case "s_monetization":
  144. if (payload.type !== "browserExtension") break;
  145. ws.send(payloads.browserExtension["2"](payload.payload.token))
  146. break;
  147. case "s_link_destination":
  148. const url = new URL(payload.url);
  149. localStorage.clear(window.location.href);
  150. if (url.searchParams.has("duf")) {
  151. window.location.href = window.atob(url.searchParams.get("duf").split("").reverse().join(""))
  152. };
  153. window.location.href = payload.url;
  154. break;
  155. }
  156. }
  157. } else if (window.location.hostname == "workink.click") {
  158. const uuid = new URLSearchParams(window.location.search).get("t")
  159. fetch(`https://redirect-api.work.ink/externalPopups/${uuid}/pageOpened`);
  160. await new Promise(r => setTimeout(r, 11 * 1000));
  161. const { destination } = await fetch(`https://redirect-api.work.ink/externalPopups/${uuid}/destination`).then(r => r.json());
  162. const url = new URL(destination);
  163. if (url.searchParams.has("duf")) {
  164. window.location.href = window.atob(url.searchParams.get("duf").split("").reverse().join(""))
  165. };
  166. window.location.href = destination;
  167. } else {
  168. if (new URL(window.location.href).searchParams.has("duf")) {
  169. var link = document.createElement("a");
  170. link.referrerPolicy = "no-referrer";
  171. link.rel = "noreferrer";
  172.  
  173. link.href = window.atob(new URL(window.location.href).searchParams.get("duf").split("").reverse().join(""));
  174. link.click();
  175. };
  176. }
  177. })();