您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add encode hex, base64 button for Voz
当前为
// ==UserScript== // @name Add Encode Button for Voz // @namespace 0x4076696e63766e // @version 0.5 // @description Add encode hex, base64 button for Voz // @author 0x4076696e63766e // @match https://voz.vn/t/* // @grant none // @license GNU General Public License (GPL) // ==/UserScript== (function () { 'use strict'; var $Editor = null; var $BBMode = false; function openDialog(encodeFunc) { const input = prompt("Nhập vào văn bản để mã hóa:"); if (input === null) return; // Người dùng đã hủy const encoded = encodeFunc(input); pickEditor(); if ($Editor) { if($Editor.tagName.toString() === 'DIV'){ $Editor.innerHTML += `<p>${encoded}</p>`; }else{ $Editor.value += `\n${encoded}`; } } } function hexEncode(str) { return Array.from(str).map(char => char.charCodeAt(0).toString(16).padStart(2, '0')).join(''); } function base64Encode(str) { return btoa(unescape(encodeURIComponent(str))); } function pickEditor() { const editorContainers = document.querySelectorAll('div.message-editorWrapper'); editorContainers.forEach(container => { const textareaEditor = container.querySelector('textarea.input'); const bbEditor = container.querySelector('div.fr-element'); const bbCodeMode = container.querySelector('#xfBbCode-1'); if(bbCodeMode) $BBMode = bbCodeMode.classList.contains('fr-active') $Editor = ($BBMode) ? textareaEditor : bbEditor console.log($BBMode) console.log($Editor) }); } function createButton(label, callback) { const button = document.createElement('div'); button.className = 'button--primary button'; button.style.marginRight = '5px'; button.textContent = label; button.onclick = callback; return button; } function insertHelper(extraDivs) { if (document.querySelectorAll("div.encode-helper").length > 0) return; extraDivs.forEach(extraDiv => { const newDiv = document.createElement('div'); newDiv.className = 'formButtonGroup encode-helper'; newDiv.appendChild(createButton('Hex', () => openDialog(hexEncode))); newDiv.appendChild(createButton('Base64', () => openDialog(base64Encode))); extraDiv.parentNode.insertBefore(newDiv, extraDiv); }); } function main() { const elements = document.querySelectorAll('div.formButtonGroup'); insertHelper(elements); } function initializeObserver() { new MutationObserver(main).observe(document.documentElement, { childList: true, subtree: true }); } document.readyState === 'loading' ? document.addEventListener('DOMContentLoaded', initializeObserver) : initializeObserver(); })();