WeChat Article URL Copier

Simplify WeChat article URL and copy it to the clipboard with a notification

  1. // ==UserScript==
  2. // @name WeChat Article URL Copier
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description Simplify WeChat article URL and copy it to the clipboard with a notification
  6. // @author You
  7. // @match https://mp.weixin.qq.com/s*
  8. // @grant GM_setClipboard
  9. // @license GNU
  10.  
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Create the "Copy URL" button
  17. const button = document.createElement('button');
  18. button.innerText = 'Copy URL';
  19. button.style.position = 'fixed';
  20. button.style.top = '10px';
  21. button.style.right = '10px';
  22. button.style.zIndex = '10000';
  23. button.style.padding = '10px 15px';
  24. button.style.backgroundColor = '#007bff';
  25. button.style.color = '#fff';
  26. button.style.border = 'none';
  27. button.style.borderRadius = '5px';
  28. button.style.cursor = 'pointer';
  29.  
  30. // Button hover effect
  31. button.onmouseover = () => {
  32. button.style.backgroundColor = '#0056b3';
  33. };
  34. button.onmouseout = () => {
  35. button.style.backgroundColor = '#007bff';
  36. };
  37.  
  38. // Create notification function
  39. const createNotification = (message) => {
  40. const notification = document.createElement('div');
  41. notification.innerText = message;
  42. notification.style.position = 'fixed';
  43. notification.style.bottom = '10px';
  44. notification.style.right = '10px';
  45. notification.style.padding = '10px 15px';
  46. notification.style.backgroundColor = '#28a745';
  47. notification.style.color = '#fff';
  48. notification.style.borderRadius = '5px';
  49. notification.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.2)';
  50. notification.style.zIndex = '10001';
  51. notification.style.fontSize = '14px';
  52. document.body.appendChild(notification);
  53.  
  54. // Automatically remove the notification after 3 seconds
  55. setTimeout(() => {
  56. notification.remove();
  57. }, 3000);
  58. };
  59.  
  60. // Button click logic
  61. button.onclick = () => {
  62. const url = new URL(window.location.href); // Get the current URL
  63. const params = url.searchParams; // Extract URL parameters
  64.  
  65. // Retrieve necessary parameters
  66. const biz = params.get('__biz');
  67. const mid = params.get('mid');
  68. const idx = params.get('idx');
  69. const sn = params.get('sn');
  70.  
  71. if (biz && mid && idx && sn) {
  72. const simplifiedURL = `https://mp.weixin.qq.com/s?__biz=${biz}&mid=${mid}&idx=${idx}&sn=${sn}`;
  73. GM_setClipboard(simplifiedURL); // Copy the simplified URL to the clipboard
  74. createNotification(`URL copied: ${simplifiedURL}`);
  75. } else {
  76. createNotification('Unable to simplify the URL. Required parameters are missing.');
  77. }
  78. };
  79.  
  80. // Append the button to the page
  81. document.body.appendChild(button);
  82. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址