Greasy Fork

Greasy Fork is available in English.

Max140

On twitter dot com, truncate tweets of > 140 characters

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Max140
// @version      0.2
// @description  On twitter dot com, truncate tweets of > 140 characters
// @author       Kevin Shay
// @match        http://tampermonkey.net/index.php?version=4.4&ext=dhdg&updated=true
// @grant        none
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @include      https://twitter.com/*
// @namespace http://greasyfork.icu/users/154233
// ==/UserScript==

(function() {
    'use strict';

    window.setTimeout(function () {
        $('.js-tweet-text').each(function () {
            var tweet = $(this).clone();
            // Emoji
            tweet.find('img').replaceWith('X');
            // External links don't count but hashtags do
            tweet.find('a').not('.twitter-hashtag').remove();
            var text = tweet.text();
            if (text.length > 140) {
                var extra = ' <span style="color:red;font-weight:bold;">+' + (text.length - 140) + '</span>';
                $(this).replaceWith($(this).text().substring(0, 140) + extra);
            }
        });
    }, 2000);
})();