🏠 Home 

t.cn Auto Redirect

Make t.cn a real link shorten service.


Install this script?
  1. // ==UserScript==
  2. // @name t.cn Auto Redirect / t.cn 自动跳转
  3. // @name:en t.cn Auto Redirect
  4. // @name:zh-CN t.cn 自动跳转
  5. // @namespace https://t.cn/
  6. // @version 0.1.1
  7. // @license MIT
  8. // @description:en Make t.cn a real link shorten service.
  9. // @description:zh-CN 让 t.cn 成为一个真正的短链接服务
  10. // @author ericdiao
  11. // @match *://t.cn/*
  12. // @match *://weibo.cn/sinaurl*
  13. // @grant none
  14. // @description Make t.cn a real link shorten service.
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. function isValidUrl(string) {
  19. try {
  20. new URL(string);
  21. } catch (_) {
  22. return false;
  23. }
  24. return true;
  25. }
  26. // Find the URL for redirect.
  27. var url = document.getElementsByClassName('desc')[0].textContent;
  28. // Do redirection.
  29. if (isValidUrl(url)) {
  30. document.getElementsByClassName('open-url')[0].children[0].textContent = "Redirecting...";
  31. window.location.replace(url);
  32. } else {
  33. alert("Userscript: Could not fetch URL for redirection. URL found: " + url);
  34. }
  35. })();