Take Twitter Link Preview Back

Take the link preview of Twitter back

当前为 2023-10-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Take Twitter Link Preview Back
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Take the link preview of Twitter back
// @author       solstice23
// @match        https://twitter.com/*
// @match        https://x.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var node = document.createElement("style");
    node.type = "text/css";
    node.appendChild(document.createTextNode(`
        body[style*='background-color: rgb(255, 255, 255)'] {
            --link-preview-text-color: #000;
        }
        body[style*='background-color: rgb(0, 0, 0)'] {
            --link-preview-text-color: #fff;
        }
        body[style*='background-color: rgb(21, 32, 43)'] {
            --link-preview-text-color: #f7f9f9;
        }
        div[data-testid='card.layoutLarge.media'] > a::after {
            content: attr(aria-label);
            font-family: sans-serif;
            display: block;
            padding: 8px 10px;
            line-height: 1.3;
            color: var(--link-preview-text-color, #000);
        }
        div[data-testid='card.layoutLarge.media'] > a > div:last-child {
            bottom: unset;
            left: unset;
            top: 10px;
            right: 10px;
        }
    `));
    var heads = document.getElementsByTagName("head");
    if (heads.length > 0) {
        heads[0].appendChild(node);
    } else {
        document.documentElement.appendChild(node);
    }
})();