无编码网址窗

显示解码后的 URL,方便手动复制到地址栏,带有关闭按钮

  1. // ==UserScript==
  2. // @name Auto Show Decoded URL
  3. // @name:zh-CN 无编码网址窗
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.1
  6. // @description 显示解码后的 URL,方便手动复制到地址栏,带有关闭按钮
  7. // @description:zh-CN 显示解码后的 URL,方便手动复制到地址栏,带有关闭按钮
  8. // @author 王大锤
  9. // @match *://*/*
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. window.addEventListener('load', function () {
  18. // 解码当前 URL
  19. var decodedURL = decodeURIComponent(window.location.href);
  20. console.log('Decoded URL:', decodedURL);
  21.  
  22. // 检查解码后的 URL 是否与原始 URL 不同
  23. if (decodedURL !== window.location.href) {
  24. // 在页面顶部显示解码后的 URL
  25. let displayDiv = document.createElement('div');
  26. displayDiv.style.position = 'fixed';
  27. displayDiv.style.top = '0';
  28. displayDiv.style.left = '0';
  29. displayDiv.style.width = '100%';
  30. displayDiv.style.backgroundColor = '#f0f0f0';
  31. displayDiv.style.padding = '10px';
  32. displayDiv.style.zIndex = '9999';
  33. displayDiv.style.textAlign = 'center';
  34. displayDiv.style.borderBottom = '2px solid #ccc';
  35.  
  36. // 添加关闭按钮
  37. let closeButton = document.createElement('span');
  38. closeButton.textContent = '×';
  39. closeButton.style.cursor = 'pointer';
  40. closeButton.style.float = 'right';
  41. closeButton.style.marginRight = '10px';
  42. closeButton.style.fontSize = '20px';
  43. closeButton.style.color = '#f00';
  44.  
  45. // 点击关闭按钮时,隐藏显示框
  46. closeButton.addEventListener('click', function() {
  47. displayDiv.style.display = 'none';
  48. });
  49.  
  50. // 添加解码后的 URL 和提示文本
  51. displayDiv.innerHTML = `<strong>解码后的 URL:</strong> <input type="text" value="${decodedURL}" style="width:70%;" id="decoded-url"> <button id="copy-url">复制</button>`;
  52. // 将关闭按钮添加到显示框
  53. displayDiv.appendChild(closeButton);
  54.  
  55. // 将显示框添加到页面
  56. document.body.appendChild(displayDiv);
  57.  
  58. // 添加复制功能
  59. document.getElementById('copy-url').addEventListener('click', function() {
  60. let urlInput = document.getElementById('decoded-url');
  61. urlInput.select();
  62. document.execCommand('copy');
  63. alert('解码后的 URL 已复制到剪贴板,请粘贴到地址栏中。');
  64. });
  65. }
  66. });
  67. })();