Twitter remove t.co

将 Twitter 中所有 t.co 转为真实链接,仅适用于新 UI

  1. // ==UserScript==
  2. // @name Twitter remove t.co
  3. // @namespace https://gf.qytechs.cn/zh-CN/users/193133-pana
  4. // @homepage https://sailboatweb.com
  5. // @version 1.0.0
  6. // @description 将 Twitter 中所有 t.co 转为真实链接,仅适用于新 UI
  7. // @author pana
  8. // @include http*://*twitter.com/*
  9. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function init() {
  17. let a_tags = $('a[href^="https://t.co/"]');
  18. $.each(a_tags, function(index, item) {
  19. let real_url;
  20. if (a_tags.eq(index).attr('data-expanded-url') !== undefined) {
  21. real_url = a_tags.eq(index).attr('data-expanded-url')
  22. } else if (item.title !== '') {
  23. real_url = item.title
  24. } else if ((a_tags.eq(index).find('div').length === 0) && (item.innerText !== "") && (item.innerText.indexOf('…') === -1)) {
  25. if (/^https?:\/\//i.test(item.innerText)) {
  26. real_url = item.innerText
  27. } else {
  28. real_url = 'http://' + item.innerText
  29. }
  30. } else {
  31. real_url = item.href
  32. }
  33. item.href = real_url
  34. })
  35. }
  36. init();
  37. let observer = new MutationObserver(function() {
  38. init()
  39. });
  40. let listenerContainer = document.body;
  41. let option = {
  42. 'childList': true,
  43. 'characterData': true,
  44. 'subtree': true,
  45. };
  46. observer.observe(listenerContainer, option)
  47. })();

QingJ © 2025

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