// ==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 // @downloadURL none // ==/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(``) } (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(`
${$(tweet).html()}
`); } }) $(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) })();