隐藏微信公众号二维码

隐藏微信公众号文章页面的二维码

  1. // ==UserScript==
  2. // @name 隐藏微信公众号二维码
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 隐藏微信公众号文章页面的二维码
  6. // @author Ethan-J
  7. // @match https://mp.weixin.qq.com/s*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 方法1:直接添加display:none样式
  16. function hideQRCode() {
  17. const qrCode = document.querySelector('.qr_code_pc');
  18. if (qrCode) {
  19. qrCode.style.display = 'none';
  20. }
  21. }
  22.  
  23. // 方法2:添加隐藏类
  24. function addCSS() {
  25. const style = document.createElement('style');
  26. style.textContent = `
  27. .qr_code_pc {
  28. display: none !important;
  29. }
  30. `;
  31. document.head.appendChild(style);
  32. }
  33.  
  34. // 页面加载完成后执行
  35. window.addEventListener('load', function() {
  36. // 使用方法1或方法2都可以
  37. // hideQRCode();
  38. addCSS();
  39. });
  40.  
  41. // 为了确保元素被隐藏,可以在DOMContentLoaded时也执行一次
  42. document.addEventListener('DOMContentLoaded', function() {
  43. // hideQRCode();
  44. addCSS();
  45. });
  46. })();

QingJ © 2025

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