Greasy Fork

Greasy Fork is available in English.

Tweetdeck media zoom

タブレット専用に選択した画像を広げて表示

当前为 2020-11-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Tweetdeck media zoom
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  タブレット専用に選択した画像を広げて表示
// @author       y_kahou
// @match        https://tweetdeck.twitter.com/
// @grant        none
// @noframes
// @require      http://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==

var $ = window.jQuery;

function __css__() {/*
.med-origlink { display: none; }
.med-flaglink { display: none; }
.med-embeditem {
    top: 0;
    bottom: 0;
}
.med-tweet {
    background: rgb(0, 0, 0, 0.8);
    right: 0px;
    left: 0px;
    transition: 0.5s;
}
.view {
    opacity: 0;
    pointer-events: none;
}

.js-med-tweet .item-box {
    padding-left: 100px;
    padding-right: 100px;
}
.js-med-tweet .account-link {
    flex: none;
}
.js-med-tweet .account-link > .nbfc{
    display: inline-block;
}
.js-med-tweet time {
    position: absolute;
    right: 100px;
}
*/}
function addStyle() {
    var css = (__css__).toString()
        .match(/[^]*\/\*([^]*)\*\/\}$/)[1]
        .replace(/\{\*/g, '/*')
        .replace(/\*\}/g, '*/');
        
    var font = $('html').css('font-family')
    css += `pre { white-space: pre-wrap; font-family: ${font}; }`
    
    $('head').append(`<style id="mystyle" type="text/css">${css}</style>`)
}
(function() {
    'use strict';
    addStyle();
    
    var tapCount = 0;
    var tapCount2 = 0;
    
    var controll = function(modal) {
        
        $(modal).on('DOMSubtreeModified propertychange', function() {
            var tweet = $('p', modal)[0]
            if (tweet) {
                $(tweet).replaceWith(`<pre>${$(tweet).html()}</pre>`);
            }
        })
        
        
        $(modal).on('touchstart', '.med-link', function(e) {
            if (!tapCount) {
                ++tapCount;
                setTimeout(() => tapCount = 0, 350);
                e.preventDefault();
            } else {
                tapCount = 0 ;
                e.stopPropagation();
            }
        })
        $(modal).on('touchstart', '.med-embeditem', function(e) {
            if (!tapCount2) {
                ++tapCount2;
                setTimeout(() => tapCount2 = 0, 350);
                $('.med-tweet').toggleClass('view')
            } else {
                tapCount2 = 0 ;
                e.preventDefault();
                $(modal).empty().hide();
            }
        })
        $(modal).on('touchstart', '.med-tweet', function(e) {
            // 余白をタップでツイート文表示切り替え
            var tgl = false
            // タッチ座標
            var x = e.touches[0].pageX
            var y = e.touches[0].pageY
            // 左余白座標
            var of = $(this).offset()
            var top    = of.top,
                left   = of.left,
                bottom = top + $(this).height(),
                right  = of.left + 100;
            if (top <= y && y <= bottom &&
                left <= x && x <= right) { tgl = true }
            
            // 右余白座標
            right = left + $(this).width()
            left = right - 100;
            if (top <= y && y <= bottom &&
                left <= x && x <= right) { tgl = true }
            
            if (tgl) {
                $('.med-tweet').toggleClass('view')
            }
            e.preventDefault();
        })
    }
    var iv = setInterval(function() {
        var modal = $('#open-modal')[0];
        if (modal) {
            clearInterval(iv);
            controll(modal);
        }
    }, 500)
})();