优化微信文章

修复了一些微信文章问题

  1. // ==UserScript==
  2. // @name 优化微信文章
  3. // @name:en FuckweixinArticle
  4. // @namespace https://gf.qytechs.cn/en/users/572221-alan636
  5. // @description 修复了一些微信文章问题
  6. // @description:en Open target link in a new tab without confirmation dialog and close the original dialog
  7. // @description:zh 修复了一些微信文章问题
  8. // @match https://mp.weixin.qq.com/*
  9. // @author alan636
  10. // @icon //res.wx.qq.com/a/wx_fed/assets/res/NTI4MWU5.ico
  11. // @version 4.0
  12. // @license Mozilla
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var semaphore = false;
  18. var observer = new MutationObserver(function(mutationsList) {
  19. mutationsList.forEach(function(mutation) {
  20. if (mutation.target.id === 'js_link_dialog_body' && mutation.target.style.display === '' && !semaphore) {
  21. semaphore = true;
  22. preventOriginalPageRedirect();
  23. simulateAllowButtonClick();
  24. setTimeout(function() { semaphore = false; }, 1000);
  25. }
  26. });
  27. });
  28. var targetNode = document.body;
  29. var config = { childList: true, subtree: true };
  30. observer.observe(targetNode, config);
  31.  
  32. function simulateAllowButtonClick() {
  33. var allowButton = document.getElementById('js_link_dialog_ok');
  34. if (allowButton) allowButton.click();
  35. }
  36.  
  37. function preventOriginalPageRedirect() {
  38. var linkDialogCancel = document.getElementById('js_link_dialog_cancel');
  39. if (linkDialogCancel) linkDialogCancel.addEventListener('click', function(event) { event.preventDefault(); });
  40. }
  41. })();
  42.  

QingJ © 2025

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