Created
December 13, 2024 03:46
-
-
Save troilus/a2624671e7357ea719ead2512f3c5716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ function decodeBase64(str) { try { return decodeURIComponent(atob(str).split('').map(function(c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }).join('')); } catch (e) { return "解码失败: " + e.message; } } function getSelectedText() { return window.getSelection().toString().trim(); } function createSelectablePopup(content) { var popup = document.createElement('div'); popup.style.cssText = ` position: fixed; top: 20%; left: 20%; width: 60%; max-height: 60%; background: white; border: 1px solid #ccc; padding: 20px; box-shadow: 0 0 10px rgba(0,0,0,0.5); z-index: 1000; overflow: auto; white-space: pre-wrap; word-wrap: break-word; %60; var closeButton = document.createElement('button'); closeButton.textContent = '关闭'; closeButton.style.cssText = %60 position: absolute; top: 10px; right: 10px; %60; closeButton.onclick = function() { document.body.removeChild(popup); }; var contentDiv = document.createElement('div'); contentDiv.textContent = content; contentDiv.style.cssText = %60 margin-top: 30px; user-select: text; %60; popup.appendChild(closeButton); popup.appendChild(contentDiv); document.body.appendChild(popup); } var selectedText = getSelectedText(); if (selectedText) { var decoded = decodeBase64(selectedText); createSelectablePopup("解码结果:\n" + decoded); } else { alert("请先选择要解码的Base64文本"); }})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment