🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Secret Message Encoder

Encodes a secret message inside another.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name             Secret Message Encoder
// @name:de          Geheime Nachrichten Kodierer
// @namespace        https://sme.luisafk.dev
// @version          1.0.1742244079066
// @description      Encodes a secret message inside another.
// @description:de   Kodiert eine geheime Nachricht in einer anderen.
// @author           LuisAFK
// @match            *://*/*
// @icon             https://sme.luisafk.dev/assets/favicon96.png
// @website          https://sme.luisafk.dev
// @grant            none
// @supportURL       https://github.com/lafkpages/sme/issues
// @run-at           document-idle
// @license          GPLv3
// ==/UserScript==

(()=>{
// src/shared/encoders.ts
var one = "​";
var zero = "‌";
var oneOne = "‎";
var zeroZero = "‏";
var oneZero = "⁡";
var zeroOne = "⁢";
var zeroZeroZero = "⁣";
var oneOneOne = "⁤";
var secretsRegEx = new RegExp(`[${zeroZeroZero}${oneOneOne}${zeroZero}${oneOne}${zeroOne}${oneZero}${zero}${one}]+`);
function binToString(b) {
  const m = b.match(/[01]{8}/g);
  if (!m) {
    return null;
  }
  let s = "";
  for (const c of m) {
    s += String.fromCodePoint(parseInt(c, 2));
  }
  return s;
}
function secretBinToString(b) {
  b = b.replace(new RegExp(zeroZeroZero, "g"), "000");
  b = b.replace(new RegExp(oneOneOne, "g"), "111");
  b = b.replace(new RegExp(zeroOne, "g"), "01");
  b = b.replace(new RegExp(oneZero, "g"), "10");
  b = b.replace(new RegExp(zeroZero, "g"), "00");
  b = b.replace(new RegExp(oneOne, "g"), "11");
  b = b.replace(new RegExp(zero, "g"), "0");
  b = b.replace(new RegExp(one, "g"), "1");
  return binToString(b);
}
function decodeSecret(s) {
  const b = s.match(secretsRegEx)?.[0];
  if (!b) {
    return null;
  }
  return secretBinToString(b);
}

// src/scriptlet/index.ts
var host = document.createElement("div");
host.id = "sme-inject-toast-host";
var shadow = host.attachShadow({ mode: "closed" });
var div = document.createElement("div");
div.id = "sme-inject-toast";
shadow.appendChild(div);
document.body.appendChild(host);
var style = document.createElement("style");
style.textContent = `
  #sme-inject-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px;
    z-index: 99999;
    background: wheat;
    border: 1px solid black;
    border-radius: 5px;
    transition: transform 0.5s ease-in-out 0s;
    transform: translateY(calc(-100% - 50px));
    white-space: pre-line;
  }

  #sme-inject-toast.show,
  #sme-inject-toast:hover {
    transform: translateY(0px);
  }
`;
shadow.appendChild(style);
document.addEventListener("select", onSelectionChange);
document.addEventListener("selectionchange", onSelectionChange);
function onSelectionChange() {
  let selectedText = window.getSelection()?.toString();
  if (!selectedText) {
    const elm = document.activeElement;
    if (elm instanceof HTMLTextAreaElement || elm instanceof HTMLInputElement) {
      if (elm.selectionStart !== null && elm.selectionEnd !== null) {
        selectedText = elm.value.slice(elm.selectionStart, elm.selectionEnd);
      }
    }
  }
  let decodedSecret = null;
  if (selectedText) {
    try {
      decodedSecret = decodeSecret(selectedText);
    } catch {}
  }
  if (decodedSecret) {
    div.classList.add("show");
    div.textContent = decodedSecret;
  } else {
    div.classList.remove("show");
  }
}

})()