replace_directly_link

11/19/2021, 9:05:58 AM

当前为 2021-11-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name replace_directly_link
  3. // @namespace Violentmonkey Scripts
  4. // @match *://*oschina*/*
  5. // @grant none
  6. // @version 1.0
  7. // @author -
  8. // @description 11/19/2021, 9:05:58 AM
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (async () => {
  13. console.info(`oschina_replace_directly_link`);
  14. let count = 0;
  15. for(const link of document.querySelectorAll('a')) {
  16. if(link.href.startsWith('https://www.oschina.net/action/GoToLink?url=')) {
  17. count ++;
  18. link.href=new URL(link).searchParams.get('url')
  19. }
  20. }
  21. console.info(`oschina_replace_directly_link processed ${count} links`);
  22. })()