// ==UserScript==
// @name Show date normally on Twitter
// @name:ja Twitter で日時を通常の表記に
// @name:ko 트위터에서 날짜와 시간을 일반 표기법으로 변경
// @name:zh-CN 在推特上显示正常的日期和时间
// @name:zh-TW 在推特上顯示正常的日期和時間
// @namespace https://greasyfork.org/en/scripts/462064-show-date-normally-on-twitter
// @version 1.20.14
// @description Like this, 70/12/31(Th) 23:59:59.
// @description:ja こんな感じです。70/12/31(Th) 23:59:59。
// @description:ko 이런 느낌입니다. 70/12/31(Th) 23:59:59。
// @description:zh-CN 看起来是这样的。70/12/31(Th) 23:59:59。
// @description:zh-TW 看起來是這樣的。70/12/31(Th) 23:59:59。
// @author AeamaN
// @contributionURL bitcoin:1DC6uWJWzzwU3iRJDXhUquv6QAYaRvtfFJ
// @match https://twitter.com/*
// @match https://mobile.twitter.com/*
// @match https://twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/*
// @match https://mobile.twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/*
// @match https://x.com/*
// @match https://mobile.x.com/*
// @require https://update.greasyfork.org/scripts/487338/1327535/PNG%20BB.js
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @run-at document-body
// ==/UserScript==
// And more. See Default valuse below.
// It's based on "https://qiita.com/libraplanet/items/0bdd7ef1a13e7af8f48f".
//
// 他にも機能があります。以下の Default valuse を確認して下さい。
// "https://qiita.com/libraplanet/items/0bdd7ef1a13e7af8f48f" を参考にしています。
(function () { /* START */
'use strict';
// //////////// Settings //////////// //
// No GUI Settings
// Default values are used
const NO_GUI = false;
// ////////////////////////////////// //
// ///////// Default valuse ///////// //
// Date formats
// 1. Do it
// 0. Do nothing
const FMT = 1;
// YE(70), YF(1970), YEU(UTC), YFU(UTC), YM(60),
// MO(12), MN(Dec), DA(31), WE(Th), HO(23), HH(11), MI(59), SE(59) and AP(PM)
const FMTS = 'YE/MO/DA(WE) HO:MI:SE';
// Month name
const JAN = 'Jan';
const FEB = 'Feb';
const MAR = 'Mar';
const APR = 'Apr';
const MAY = 'May';
const JUN = 'Jun';
const JUL = 'Jul';
const AUG = 'Aug';
const SEP = 'Sep';
const OCT = 'Oct';
const NOV = 'Nov';
const DEC = 'Dec';
// Week label
const SUN = '😊';
const MON = '😭';
const TUE = 'Tu';
const WED = 'We';
const THU = 'Th';
const FRI = 'Fr';
const SAT = 'Sa';
// AM and PM
const AM = 'AM';
const PM = 'PM';
// Blue bird returns
const BBR = false;
// Replace with orig images(wasted traffic occurs)
const ORIG_IMG = false;
// Slightly wider TL
const WTL = false;
// Eye Care Mode at default background
const EC_MODE = true;
// Hide promotions
const HIDE_PP = true;
// Hide Who to follow
const HIDE_WF = true;
// Hide DM drawer
const HIDE_DMD = true;
// Hide Get Verified
const HIDE_GV = true;
// Fine engagement
// 1. Live
// 2. Normal
// 0. Do nothing
const FINE_EGM = 0;
// Fix videos quality
// 1. Maximum
// 2. Minimum
// 0. Do nothing
const FIX_VQ = 1;
// Loop interval(ms)
const INTL = 800;
// ////////////////////////////////// //
const MYNAME = 'sdnt12014';
const LANG = document.documentElement.getAttribute('lang');
const SETS = {
'fmt': ['r', FMT], 'fmts': ['t', FMTS],
'jan': ['t', JAN, 'm', 0], 'feb': ['t', FEB, 'm', 1], 'mar': ['t', MAR, 'm', 2], 'apr': ['t', APR, 'm', 3],
'may': ['t', MAY, 'm', 4], 'jun': ['t', JUN, 'm', 5], 'jul': ['t', JUL, 'm', 6], 'aug': ['t', AUG, 'm', 7],
'sep': ['t', SEP, 'm', 8], 'oct': ['t', OCT, 'm', 9], 'nov': ['t', NOV, 'm', 10], 'dec': ['t', DEC, 'm', 11],
'sun': ['t', SUN, 'w', 0], 'mon': ['t', MON, 'w', 1], 'tue': ['t', TUE, 'w', 2], 'wed': ['t', WED, 'w', 3],
'thu': ['t', THU, 'w', 4], 'fri': ['t', FRI, 'w', 5], 'sat': ['t', SAT, 'w', 6],
'am': ['t', AM], 'pm': ['t', PM],
'bbr': ['c', BBR],
'orig_img': ['c', ORIG_IMG],
'wtl': ['c', WTL],
'ec_mode': ['c', EC_MODE],
'hide_pp': ['c', HIDE_PP],
'hide_wf': ['c', HIDE_WF],
'hide_dmd': ['c', HIDE_DMD],
'hide_gv': ['c', HIDE_GV],
'fine_egm': ['r', FINE_EGM],
'fix_vq': ['r', FIX_VQ],
'intl': ['t', INTL]
};
const SEL_BR_ID =
'div#placeholder[aria-label="Loading…"] g path, ' +
'svg#loading-x-anim-0 g path, svg#loading-x-anim-1 g path, ' +
'svg#loading-x-anim-2 g path, svg#loading-x-anim-3 g path';
const SEL_BR_H = 'header[role="banner"] h1[role="heading"] g path'; // ホーム
const SEL_BR_M = 'div[data-testid="Dropdown"] a[href="/i/premium_sign_up"] g path'; // もっと見る
const SEL_BR_V = 'header[role="banner"] nav g path'; // 認証済み
const SEL_BR_VM = 'div#layers div[role="group"] div[role="dialog"] a g path'; // モバイル認証済み
const SEL_BR_L = 'div[role="dialog"] div[aria-labelledby="modal-header"] svg.r-lrvibr g path'; // ログイン
const SEL_BR_T = 'div#react-root main svg.r-lrvibr g path'; // トップ
const SEL_BR_TM = 'div#react-root div[data-testid="TopNavBar"] svg.r-lrvibr g path'; // モバイルトップ
const SEL_BR_O =
'div#layers div[role="alertdialog"] div[role="group"] div[data-testid="confirmationSheetDialog"] g path';
// ログアウト
const DATA_BR_X = 'M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99';
const DATA_BR_BB =
'M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1' +
'.897.922-2.958 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0' +
' .364.042.718.12 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342' +
' 0 1.616.823 3.043 2.072 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 ' +
'4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3 0-.593-.028-.877-.082.593 1.85 2' +
'.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376 0-.747-.022-1.112' +
'-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254 0-.2-.' +
'005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z';
const DATA_BR_FILL_N = 'none';
const DATA_BR_FILL_LB = '#1da1f2ff';
const DATA_BR_FILL_DB = '#1d9bf0ff';
const DATA_BR_S = 'currentColor';
const DATA_BR_SW = '2';
const REPETIT = {
'ja': ['会話', 'Xユーザーの', ''],
'ko': ['대화', 'X에서 ', ''],
'zh-Hant': ['對話', 'X 上的 ', ''],
'zh': ['对话', 'X 上的 ', ''],
'ru': ['Переписка', ' в X: «', ': «'],
'de': ['Konversation', ' auf X: „', ': „'],
'it': ['Conversazione', ' su X: "', ': "'],
'fr': ['Conversation', ' sur X : "', ' : "'],
'pt': ['Conversa', ' no X: "', ': "'],
'en': ['Conversation', ' on X: "', ': "'] // Add your language
};
const REPETIT_L = REPETIT[LANG] ?? ['', '', ''];
const SEL_OI_D = 'div[style*="background-image:"]';
const SEL_OI_I = 'img';
const REGEX_OI = /^(.+pbs\.twimg\.com\/[^?]+\?format=\w+)(&|&)(name=)(\w+)([")]*)$/;
const SEL_HP = 'path[d^="M19.498 3h-15c-1.381 0-2.5 1.12-2.5 2.5v13c0 1.38 1.119 2.5"]';
const SEL_HP_2 = 'main div[data-testid="sidebarColumn"] section div[data-testid="trend"] div.r-14gqq1x ' +
'span.css-1jxf684.r-bcqeeo.r-qvutc0'; // def-ja, def-en, ble-ja, ble-en
const SEL_HP_3 = 'main div[data-testid="primaryColumn"] section article ' +
'span.css-1jxf684.r-bcqeeo.r-qvutc0.r-poiln3';
const SEL_HP_4 =
'main div[data-testid="primaryColumn"] section ' +
'span.css-901oao.css-16my406.r-bcqeeo.r-qvutc0';
// Lone label def-ja, def-en, ble-ja, ble-en
const PROMO = {
'ja': 'によるプロモーション$',
'ko': ' 님이 프로모션함$',
'zh-Hant': '^由 .+ 推廣$',
'zh': '^由 .+ 推广$',
'ru': '^Реклама от ',
'de': '^Gesponsert von ',
'it': '^Sponsorizzato da ',
'fr': '^Sponsorisé par ',
'pt': '^Promovido por ',
'en': '^Promoted by ' // Add your language
};
const PROMO_L = PROMO[LANG] ?? PROMO['en'];
const REGEX_HP = new RegExp(PROMO_L, 'i');
const PROMO_2 = {
'ja': 'プロモポスト',
'ko': 'Promoted Post',
'zh-Hant': '推廣貼文',
'zh': 'Promoted Post',
'ru': 'Promoted Post',
'de': 'Gesponserter Post',
'it': 'Promoted Post',
'fr': 'Promoted Post',
'pt': 'Post promovido',
'en': 'Promoted Post' // Add your language
};
const PROMO_L_2 = PROMO_2[LANG] ?? PROMO_2['en'];
const PATT_HW =
'^[^:]+://[^/]+/$|' +
'^[^:]+://[^/]+/(' +
'compose|' + // pop up
'search-advanced|' + // pop up
'home|' + // 除外?
'search|' +
'i/display|' + // pop up
'i/flow|' + // pop up
'i/keyboard_shortcuts|' + // pop up
'i/verified-orgs-signup|' + // pop up、追加
'i/verified-choose|' + // pop up、追加
'i/premium_sign_up|' + // pop up、追加
'i/connect_people|' +
'i/topics|' +
'i/spaces/start|' + // pop up、追加
'i/verified-application|' + // pop up、追加
'i/verified-get-verified|' + // pop up、追加
'[^/]+/followers|' +
'[^/]+/following|' +
'[^/]+/lists|' +
'[^/]+/status/|' + // 両方、WTFのみ除外
'[^/]+/topics|' +
'[^/]+/creator-subscriptions|' + // 追加
'[^/]+/superfollows|' + // 追加
'[^/]+/verified_followers' + // 追加
')';
const REGEX_HW = new RegExp(PATT_HW, 'i');
const SEL_HD = 'div[data-testid="DMDrawer"]';
const SEL_HG = 'aside.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-1mmae3n.r-3pj75a';
const SEL_HG_2 = 'main section div[data-testid="cellInnerDiv"] h1[role="heading"] span.css-1jxf684.r-bcqeeo.r-qvutc0';
// def-ja, def-en, ble-ja, ble-en
const TC_HG = {
'gv': {
'ja': '認証を受ける',
'ko': '인증 받기',
'zh-Hant': '獲得認證',
'zh': '获得认证',
'ru': 'Подтвердить подлинность',
'de': 'Lass dich verifizieren',
'it': 'Ottieni la verifica',
'fr': 'Obtenez la certification',
'pt': 'Obter verificação',
'en': 'Get Verified' // Add your language
},
'sp': {
'ja': 'プレミアムにサブスクライブ',
'ko': 'Subscribe to Premium',
'zh-Hant': '訂閱 Premium',
'zh': 'Subscribe to Premium',
'ru': 'Subscribe to Premium',
'de': 'Premium abonnieren',
'it': 'Subscribe to Premium',
'fr': 'Subscribe to Premium',
'pt': 'Assine o Premium',
'en': 'Subscribe to Premium' // Add your language
},
'spylp': {
'ja': '長いポストを作成するには、プレミアムにサブスクライブしてください',
'ko': 'Premium을 구독하고 나만의 긴 게시물을 작성해 보세요',
'zh-Hant': '訂閱 Premium 以撰寫你自己的更長貼文',
'zh': '订阅 Premium,撰写自己的长帖',
'ru': 'Подпишитесь на Premium, чтобы писать собственные длинные посты',
'de': 'Abonniere Premium, wenn du deine eigenen längeren Posts schreiben möchtest',
'it': 'Per scrivere post più lunghi, abbonati a Premium',
'fr': 'Abonnez-vous à Premium pour écrire vos propres posts plus longs.',
'pt': 'Assine o Premium para escrever posts mais longos',
'en': 'Subscribe to Premium to write your own longer posts' // Add your language
},
'gafp': {
'ja': 'プレミアムプラスで広告をなくす',
'ko': 'Go ad-free with Premium+',
'zh-Hant': 'Go ad-free with Premium+',
'zh': 'Go ad-free with Premium+',
'ru': 'Go ad-free with Premium+',
'de': 'Go ad-free with Premium+',
'it': 'Go ad-free with Premium+',
'fr': 'Go ad-free with Premium+',
'pt': 'Go ad-free with Premium+',
'en': 'Go ad-free with Premium+' // Add your language or change a value
},
'gaf': {
'ja': '広告をなくす',
'ko': 'Go ad free',
'zh-Hant': 'Go ad free',
'zh': 'Go ad free',
'ru': 'Go ad free',
'de': 'Go ad free',
'it': 'Go ad free',
'fr': 'Go ad free',
'pt': 'Go ad free',
'en': 'Go ad free' // Add your language or change a value
},
'txp': {
'ja': 'TweetDeckはX Proになりました',
'ko': 'TweetDeck is now X Pro',
'zh-Hant': 'TweetDeck is now X Pro',
'zh': 'TweetDeck is now X Pro',
'ru': 'TweetDeck is now X Pro',
'de': 'TweetDeck is now X Pro',
'it': 'TweetDeck is now X Pro',
'fr': 'TweetDeck is now X Pro',
'pt': 'TweetDeck is now X Pro',
'en': 'TweetDeck is now X Pro' // Add your language or change a value
}
};
const GV_L = TC_HG.gv[LANG] ?? TC_HG.gv['en'];
const SP_L = TC_HG.sp[LANG] ?? TC_HG.sp['en'];
const SPYLP_L = TC_HG.spylp[LANG] ?? TC_HG.spylp['en'];
const GAFP_L = TC_HG.gafp[LANG] ?? TC_HG.gafp['en'];
const GAF_L = TC_HG.gaf[LANG] ?? TC_HG.gaf['en'];
const TXP_L = TC_HG.txp[LANG] ?? TC_HG.txp['en'];
const SEL_FE_R =
'main div[data-testid="primaryColumn"] section article ' +
'button.css-175oi2r.r-1777fci.r-bztko3.r-lrvibr.r-1loqt21.r-1ny4l3l[data-testid*="reply"] ' +
'div>span[data-testid="app-text-transition-container"]>span'; // 一つ上
const SEL_FE_T =
'main div[data-testid="primaryColumn"] section article ' +
'button.css-175oi2r.r-1777fci.r-bztko3.r-lrvibr.r-1loqt21.r-1ny4l3l[data-testid*="retweet"] ' +
'div>span[data-testid="app-text-transition-container"]>span';
const SEL_FE_L =
'main div[data-testid="primaryColumn"] section article ' +
'button.css-175oi2r.r-1777fci.r-bztko3.r-lrvibr.r-1loqt21.r-1ny4l3l[data-testid*="like"] ' +
'div>span[data-testid="app-text-transition-container"]>span';
const SEL_FE_B =
'main div[data-testid="primaryColumn"] section article ' +
'button.css-175oi2r.r-1777fci.r-bztko3.r-lrvibr.r-1loqt21.r-1ny4l3l[data-testid*="bookmark"] ' +
'div>span[data-testid="app-text-transition-container"]>span';
const SEL_ADD_SPAN = 'span.us-' + MYNAME;
const SEL_FEVD =
'main div[data-testid="primaryColumn"] section article ' +
'div.css-175oi2r.r-1d09ksm.r-1471scf.r-18u37iz.r-1wbh5a2>' +
'div>span>div>span[data-testid="app-text-transition-container"]>span>span:not(.us-' + MYNAME + ')';
// 表示回数は減らない、0の時は無い
const SEL_FEVD_2 =
'button.css-175oi2r.r-1777fci.r-bztko3.r-lrvibr.r-1loqt21.r-1ny4l3l[data-testid*="retweet"] ' +
'div>span[data-testid="app-text-transition-container"]>span'; // 一つ上
const SEL_FEVT =
'main div[data-testid="primaryColumn"] section article ' +
'a[href$="/analytics"][aria-label][role="link"]>div>div>span[data-testid="app-text-transition-container"]>' +
'span>span:not(.us-' + MYNAME + ')'; // 二つ下から消える
const SEL_ADD_DIV_FEP = 'div.us-' + MYNAME + '-fep';
const SEL_FEP =
'main div[data-testid="primaryColumn"] div[aria-label] ' +
'h2[role="heading"]~div.css-146c3p1.r-n6v787.r-1cwl3u0';
const SEL_FEP_M =
'div#layers div[data-testid="TopNavBar"] div.css-175oi2r.r-1habvwh ' +
'h2[role="heading"]~div.css-146c3p1.r-1enofrn.r-fxxt2n';
const SEL_FEP_2 =
'script[data-testid="UserProfileSchema-test"]';
const REGEX_TXSH = /#EXT-X-STREAM-INF.*[^-]BANDWIDTH=(\d+).*\r?\n\/.+$/gm;
const SEL_RD =
'main div[data-testid="primaryColumn"] section article time[datetime*=":"]';
const SEL_RD_2 =
'div[aria-labelledby="modal-header"] div[data-testid^="User-Name"] time[datetime]';
const SEL_RD_3 =
'div[aria-labelledby="modal-header"] div[aria-label] time[datetime]';
const SEL_RD_4 =
'main section[aria-labelledby="detail-header"] article div[data-testid^="User-Name"] time[datetime]';
const SEL_RD_4M =
'main div.css-175oi2r.r-1ua6aaf.r-th6na.r-1phboty article div[data-testid^="User-Name"] time[datetime]';
const SEL_RD_5 =
'main section div[data-testid="conversation"] div[aria-label] time[datetime]'; // DM list
let time_fine_egm = Date.now();
let muts = true;
let observer = new MutationObserver(function (mutations) {
muts = mutations;
});
let orig_xhr_open;
let sets = {};
function makeDalg() {
let dalg = document.createElement('div');
dalg.className = 'us-' + MYNAME;
dalg.style.all = 'initial';
dalg.style.backgroundColor = 'rgb(235, 235, 235)';
dalg.style.border = '3px outset';
dalg.style.borderRadius = '1%';
dalg.style.display = 'none';
dalg.style.fontFamily = 'monospace';
dalg.style.fontSize = '12px';
dalg.style.height = '420px';
dalg.style.width = '480px';
dalg.style.paddingLeft = '2px';
dalg.style.paddingRight = '2px';
dalg.style.position = 'fixed';
dalg.style.right = '8px';
dalg.style.top = '8px';
dalg.style.zIndex = '2147483647';
dalg.style.overflow = 'auto';
const HTML =
'<span style="all: initial; font-size: 130%; font-weight: bold; line-height: 210%">' +
'Settings' + ' - ' + GM_info.script.name + ' ' + GM_info.script.version +
'</span><br />\n' +
'<input type="radio" name="fmt" value="1" class="top_r" />' +
'Format:<br />\n' +
' ' +
'<input type="text" name="fmts" class="top_t1" />(*1)<br />\n' +
' ' +
'MN in the format:<br />\n' +
' ' +
'<input type="text" name="jan" class="top_t2" />' +
'<input type="text" name="feb" class="top_t2" />' +
'<input type="text" name="mar" class="top_t2" />' +
'<input type="text" name="apr" class="top_t2" />' +
'<input type="text" name="may" class="top_t2" />' +
'<input type="text" name="jun" class="top_t2" /><br />\n' +
' ' +
'<input type="text" name="jul" class="top_t2" />' +
'<input type="text" name="aug" class="top_t2" />' +
'<input type="text" name="sep" class="top_t2" />' +
'<input type="text" name="oct" class="top_t2" />' +
'<input type="text" name="nov" class="top_t2" />' +
'<input type="text" name="dec" class="top_t2" /><br />\n' +
' ' +
'WE in the format:<br />\n' +
' ' +
'<input type="text" name="sun" class="top_t2" />' +
'<input type="text" name="mon" class="top_t2" />' +
'<input type="text" name="tue" class="top_t2" />' +
'<input type="text" name="wed" class="top_t2" />' +
'<input type="text" name="thu" class="top_t2" />' +
'<input type="text" name="fri" class="top_t2" />' +
'<input type="text" name="sat" class="top_t2" />(*2)<br />\n' +
' ' +
'AP in the format:<br />\n' +
' ' +
'<input type="text" name="am" class="btm_t" />' +
'<input type="text" name="pm" class="btm_t" /><br />\n' +
'<input type="radio" name="fmt" value="0" class="btm_r" />Do nothing<br /><br />\n' +
'<input type="checkbox" name="bbr" class="top_c" />BB returns' +
' ' +
' ' +
'<input type="checkbox" name="orig_img" class="mid_c" />Replace with orig images(*3)<br />\n' +
'<input type="checkbox" name="wtl" class="mid_c" />Widen slightly TL' +
' ' +
'<input type="checkbox" name="ec_mode" class="btm_c" />Eye Care Mode at default BG<br />\n' +
'<input type="checkbox" name="hide_pp" class="top_c" />Hide promotions' +
' ' +
'<input type="checkbox" name="hide_wf" class="mid_c" />Hide Who to follow<br />\n' +
'<input type="checkbox" name="hide_dmd" class="mid_c" />Hide DM drawer' +
' ' +
'<input type="checkbox" name="hide_gv" class="btm_c" />Hide Get Verified(*4)<br /><br />\n' +
'<input type="radio" name="fine_egm" value="1" class="top_r" />Fine engagement(live)' +
' ' +
'<input type="radio" name="fine_egm" value="2" class="top_r" />Fine engagement(normal)<br />\n' +
'<input type="radio" name="fine_egm" value="0" class="btm_r" />Do nothing<br /><br />\n' +
'<input type="radio" name="fix_vq" value="1" class="top_r" />at maximum video quality' +
' ' +
'<input type="radio" name="fix_vq" value="2" class="top_r" />at minimum video quality<br />\n' +
'<input type="radio" name="fix_vq" value="0" class="btm_r" />Do nothing(*5)<br /><br />\n' +
'<span style="all: initial; font-size: 100%">' +
'Loop interval(ms) ' +
'</span><input type="text" name="intl" class="top_t3" />(*5)<br />\n' +
'<br />\n' +
'<span style="all: initial; font-size: 100%; line-height: 140%">' +
'(*1)Symbols YE, YF, YEU(UTC), YFU(UTC), YM,<br />\n' +
' ' +
'MO, MN, DA, WE, HO, HH, MI, SE and AP are available<br />\n' +
'(*1)Example:<br />\n' +
' ' +
'YE/MO/DA(WE) HO:MI:SE >> 70/12/31(Th) 23:59:59<br />\n' +
' ' +
'WE, MN DA, YF-HH:MI:SE AP >> Th, Dec 31, 1970-11:59:59 PM<br />\n' +
' ' +
'YFU/MO/DA HO:MI(UTC) >> 1970/12/31 23:59(UTC)<br />\n' +
' ' +
'MYM/MO/DA HO:MI >> M60/01/01 07:59<br />\n' +
'(*2)Sunday origin (*3)wasted traffic occurs<br />\n' +
'(*4)may need to edit section "Add your language or change a value"<br />\n' +
' ' +
'in the script<br />\n' +
'(*5)Restart required' +
'</span><br />\n' +
' ' +
' ' +
'<input type="button" class="top_b" value="Cancel" />\n' +
'<input type="button" class="top_b" value="Set default" />\n' +
'<input type="button" class="top_b" value="Save & Close" />\n' +
'<br /><br /><br /><br /><br /><br /><br /><br />\n';
dalg.innerHTML = HTML;
for (let e of dalg.querySelectorAll('input.top_r, input.mid_r, input.btm_r')) {
e.style.all = 'initial';
e.style.appearance = 'auto';
e.style.marginRight = '1px';
e.style.marginTop = '1px';
}
for (let e of dalg.querySelectorAll('input.top_c, input.mid_c, input.btm_c')) {
e.style.all = 'initial';
e.style.appearance = 'auto';
e.style.marginRight = '1px';
e.style.marginTop = '1px';
}
for (let e of dalg.querySelectorAll('input.top_t1')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(255, 255, 255)';
e.style.fontFamily = 'monospace';
e.style.fontSize = '100%';
e.style.marginLeft = '4px';
e.style.marginRight = '1px';
e.style.marginTop = '2px';
e.style.marginBottom = '0px';
e.style.paddingLeft = '1px';
e.style.paddingRight = '1px';
e.style.paddingTop = '1px';
e.style.paddingBottom = '1px';
e.style.width = '38%';
e.setAttribute('size', '28');
}
for (let e of dalg.querySelectorAll('input.top_t2')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(255, 255, 255)';
e.style.fontFamily = 'monospace';
e.style.fontSize = '100%';
e.style.marginLeft = '4px';
e.style.marginRight = '1px';
e.style.marginTop = '2px';
e.style.marginBottom = '0px';
e.style.paddingLeft = '1px';
e.style.paddingRight = '1px';
e.style.paddingTop = '1px';
e.style.paddingBottom = '1px';
e.style.width = '9%';
e.setAttribute('size', '5');
}
for (let e of dalg.querySelectorAll('input.top_t3')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(255, 255, 255)';
e.style.fontFamily = 'monospace';
e.style.fontSize = '100%';
e.style.marginLeft = '4px';
e.style.marginRight = '1px';
e.style.marginTop = '2px';
e.style.marginBottom = '0px';
e.style.paddingLeft = '1px';
e.style.paddingRight = '1px';
e.style.paddingTop = '1px';
e.style.paddingBottom = '1px';
e.style.width = '14%';
e.setAttribute('size', '10');
}
for (let e of dalg.querySelectorAll('input.btm_t')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(255, 255, 255)';
e.style.fontFamily = 'monospace';
e.style.fontSize = '100%';
e.style.marginLeft = '4px';
e.style.marginRight = '1px';
e.style.marginTop = '2px';
e.style.marginBottom = '0px';
e.style.paddingLeft = '1px';
e.style.paddingRight = '1px';
e.style.paddingTop = '1px';
e.style.paddingBottom = '1px';
e.style.width = '9%';
e.setAttribute('size', '5');
}
for (let e of dalg.querySelectorAll('input.top_b')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(190, 190, 190)';
e.style.borderRadius = '10%';
e.style.cursor = 'default';
e.style.fontSize = '110%';
e.style.marginTop = '26px';
e.style.marginBottom = '0px';
e.style.paddingTop = '6px';
e.style.paddingBottom = '6px';
e.style.textAlign = 'center';
e.style.width = '90px';
}
return dalg;
}
function makeFunc(dalg) {
dalg.addEventListener(
'click',
function (event) { event.stopPropagation(); },
false
);
dalg.querySelector('input[value="Cancel"]').addEventListener(
'click',
function () { dalg.style.display = 'none'; },
false
);
dalg.querySelector('input[value="Cancel"]').addEventListener(
'mouseenter',
function (event) { event.target.style.backgroundColor = 'rgb(170, 170, 170)'; },
false
);
dalg.querySelector('input[value="Cancel"]').addEventListener(
'mouseleave',
function (event) { event.target.style.backgroundColor = 'rgb(190, 190, 190)'; },
false
);
dalg.querySelector('input[value="Set default"]').addEventListener(
'click',
function () {
for (let v in SETS) {
if (SETS[v][0] == 'r') {
dalg.querySelector('input[name="' + v + '"][value="' + SETS[v][1] + '"]').checked = true;
} else if (SETS[v][0] == 'c') {
dalg.querySelector('input[name="' + v + '"]').checked = SETS[v][1];
} else {
dalg.querySelector('input[name="' + v + '"]').value = SETS[v][1];
}
}
},
false
);
dalg.querySelector('input[value="Set default"]').addEventListener(
'mouseenter',
function (event) {event.target.style.backgroundColor = 'rgb(170, 170, 170)';},
false
);
dalg.querySelector('input[value="Set default"]').addEventListener(
'mouseleave',
function (event) {event.target.style.backgroundColor = 'rgb(190, 190, 190)';},
false
);
dalg.querySelector('input[value="Save & Close"]').addEventListener(
'click',
function () {
for (let v in SETS) {
if (SETS[v][0] == 'r') {
for (let e of dalg.querySelectorAll('input[name="' + v + '"]')) {
if (e.checked) {
sets[v] = +e.value;
break;
}
}
} else if (v == 'intl') {
sets[v] = +dalg.querySelector('input[name="' + v + '"]').value;
} else if (SETS[v][0] == 't') {
sets[v] = dalg.querySelector('input[name="' + v + '"]').value;
} else {
sets[v] = dalg.querySelector('input[name="' + v + '"]').checked;
}
}
for (let v in SETS) {
GM_setValue(v, sets[v]);
}
dalg.style.display = 'none';
},
false
);
dalg.querySelector('input[value="Save & Close"]').addEventListener(
'mouseenter',
function (event) { event.target.style.backgroundColor = 'rgb(170, 170, 170)'; },
false
);
dalg.querySelector('input[value="Save & Close"]').addEventListener(
'mouseleave',
function (event) { event.target.style.backgroundColor = 'rgb(190, 190, 190)'; },
false
);
}
function initGUI() {
for (let v in SETS) {
if (GM_getValue(v) === undefined) {
GM_setValue(v, SETS[v][1]);
} else {
sets[v] = GM_getValue(v);
}
}
let dalg = makeDalg();
makeFunc(dalg);
document.body.appendChild(dalg);
GM_registerMenuCommand('Settings', function () {
if (dalg.style.display == 'none') {
for (let v in SETS) {
if (SETS[v][0] == 'r') {
dalg.querySelector('input[name="' + v + '"][value="' + sets[v] + '"]').checked = true;
} else if (SETS[v][0] == 'c') {
dalg.querySelector('input[name="' + v + '"]').checked = sets[v];
} else {
dalg.querySelector('input[name="' + v + '"]').value = sets[v];
}
}
dalg.style.display = 'block';
}
});
}
function fmtDate(fmt, date) {
let datetime;
if (sets.fmts.indexOf('YEU') >= 0 || sets.fmts.indexOf('YFU') >= 0) {
const MO_N = date.getUTCMonth();
const WE_N = date.getUTCDay();
const HO_N = date.getUTCHours();
datetime = {
'YEU': date.getUTCFullYear().toString().slice(-2),
'YFU': date.getUTCFullYear(),
'MO': ('0' + (MO_N + 1)).slice(-2),
'MN': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'm' && e[1][3] == MO_N) return true;
})[0][0]
],
'DA': ('0' + date.getUTCDate()).slice(-2),
'WE': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'w' && e[1][3] == WE_N) return true;
})[0][0]
],
'HO': ('0' + HO_N).slice(-2),
'HH':
HO_N == 0 ? '12' :
HO_N >= 1 && HO_N <= 12 ? ('0' + HO_N).slice(-2) :
HO_N >= 13 ? ('0' + (HO_N - 12)).slice(-2) :
'?',
'MI': ('0' + date.getUTCMinutes()).slice(-2),
'SE': ('0' + date.getUTCSeconds()).slice(-2),
'AP': HO_N < 12 ? sets.am : sets.pm
};
} else if (sets.fmts.indexOf('YM') >= 0) {
date.setUTCHours(date.getUTCHours() + 8);
const MO_N = date.getUTCMonth();
const WE_N = date.getUTCDay();
const HO_N = date.getUTCHours();
datetime = {
'YM': date.getUTCFullYear() - 1911,
'MO': ('0' + (MO_N + 1)).slice(-2),
'MN': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'm' && e[1][3] == MO_N) return true;
})[0][0]
],
'DA': ('0' + date.getUTCDate()).slice(-2),
'WE': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'w' && e[1][3] == WE_N) return true;
})[0][0]
],
'HO': ('0' + HO_N).slice(-2),
'HH':
HO_N == 0 ? '12' :
HO_N >= 1 && HO_N <= 12 ? ('0' + HO_N).slice(-2) :
HO_N >= 13 ? ('0' + (HO_N - 12)).slice(-2) :
'?',
'MI': ('0' + date.getUTCMinutes()).slice(-2),
'SE': ('0' + date.getUTCSeconds()).slice(-2),
'AP': HO_N < 12 ? sets.am : sets.pm
};
} else {
const MO_N = date.getMonth();
const WE_N = date.getDay();
const HO_N = date.getHours();
datetime = {
'YE': date.getFullYear().toString().slice(-2),
'YF': date.getFullYear(),
'MO': ('0' + (MO_N + 1)).slice(-2),
'MN': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'm' && e[1][3] == MO_N) return true;
})[0][0]
],
'DA': ('0' + date.getDate()).slice(-2),
'WE': sets[
Object.entries(SETS).filter(function (e) {
if (e[1][2] == 'w' && e[1][3] == WE_N) return true;
})[0][0]
],
'HO': ('0' + HO_N).slice(-2),
'HH':
HO_N == 0 ? '12' :
HO_N >= 1 && HO_N <= 12 ? ('0' + HO_N).slice(-2) :
HO_N >= 13 ? ('0' + (HO_N - 12)).slice(-2) :
'?',
'MI': ('0' + date.getMinutes()).slice(-2),
'SE': ('0' + date.getSeconds()).slice(-2),
'AP': HO_N < 12 ? sets.am : sets.pm
};
}
let ret = sets.fmts;
for (let d in datetime) {
ret = ret.replace(d, datetime[d]);
}
return ret;
}
function BBReturn() {
let elms = document.querySelectorAll(
SEL_BR_ID + ', ' + SEL_BR_H + ', ' + SEL_BR_M + ', ' + SEL_BR_V + ', ' + SEL_BR_VM + ', ' +
SEL_BR_L + ', ' + SEL_BR_T + ', ' +SEL_BR_TM + ', ' +SEL_BR_O
);
let sm; // Temp.
for (let e of elms) {
if (e.getAttribute('d').startsWith(DATA_BR_X)) {
if (e.closest(
'header[role="banner"] nav g, ' +
'div[data-testid="Dropdown"] a[href="/i/premium_sign_up"] g, ' +
'div[role="dialog"] a g'
)) {
sm = muts;
e.setAttribute('d', DATA_BR_BB);
e.setAttribute('fill', DATA_BR_FILL_N);
e.setAttribute('stroke', DATA_BR_S);
e.setAttribute('stroke-width', DATA_BR_SW);
muts = sm;
} else if (e.closest('div#placeholder[aria-label="Loading…"]') ||
e.closest('svg[id^="loading-x-anim-"]')
) {
sm = muts;
e.setAttribute('d', DATA_BR_BB);
e.setAttribute('fill', DATA_BR_FILL_LB);
muts = sm;
} else {
sm = muts;
e.setAttribute('d', DATA_BR_BB);
e.setAttribute('fill', DATA_BR_FILL_DB);
muts = sm;
}
}
}
const TITLE = document.title;
let elm = document.querySelector('head link[rel="shortcut icon"]');
let elm_2 = document.querySelector('head link[rel="apple-touch-icon"]');
let elm_3 = document.querySelector('main div[data-testid="primaryColumn"] section>h1');
sm = muts;
if (
elm &&
!/favicons\/twitter\.2\.ico$/.test(elm.getAttribute('href')) &&
!/^\([0-9]+\) /.test(document.title)
) {
elm.setAttribute('href', '//abs.twimg.com/favicons/twitter.2.ico');
} else if (
elm &&
!/favicons\/twitter-pip\.2\.ico$/.test(elm.getAttribute('href')) &&
/^\([0-9]+\) /.test(document.title)
) {
elm.setAttribute('href', '//abs.twimg.com/favicons/twitter-pip.2.ico');
}
if (
elm_2 &&
/responsive-web\/client-web[-a-z]*\/icon-ios\.77d25eba\.png$/.test(elm_2.getAttribute('href'))
) {
elm_2.setAttribute('href', 'data:image/png;base64,' + PNG_BB);
}
let rt = TITLE.replace(/ \/ X$/, ' / Twitter');
if (elm_3 && elm_3.textContent == REPETIT_L[0]) rt = rt.replace(REPETIT_L[1], REPETIT_L[2]);
if (TITLE != rt) document.title = rt;
muts = sm;
}
function origImg() {
let elms = document.querySelectorAll(SEL_OI_D + ', ' + SEL_OI_I);
for (let e of elms) {
let sm; // Temp.
if (/div/i.test(e.tagName)) {
let r = REGEX_OI.exec(e.style.backgroundImage);
if (r && r[4] != 'orig') {
sm = muts;
e.style.backgroundImage = r[1] + r[2] + r[3] + 'orig' + r[5];
muts = sm;
continue;
}
continue;
}
let r = REGEX_OI.exec(e.getAttribute('src'));
if (r && r[4] != 'orig') {
sm = muts;
e.setAttribute('src', r[1] + r[2] + r[3] + 'orig' + r[5]);
muts = sm;
continue;
}
}
}
function wideTL() {
let elms = document.querySelectorAll('div.css-175oi2r.r-aqfbo4[data-testid="sidebarColumn"]');
let sm; // Temp.
if (!document.querySelector('head style.' + 'us-' + MYNAME + '-' + 'c')) {
let style_a = document.createElement('style');
style_a.className = 'us-' + MYNAME + '-' + 'a';
style_a.textContent =
'div.css-175oi2r.r-f8sm7e.r-13qz1uu.r-1ye8kvj' +
'{max-width: 660px;}';
let style_b = document.createElement('style');
style_b.className = 'us-' + MYNAME + '-' + 'b';
style_b.textContent =
'div[role="dialog"] div.css-175oi2r.r-f8sm7e.r-13qz1uu.r-1ye8kvj' +
'{max-width: 600px;}';
let style_c = document.createElement('style');
style_c.className = 'us-' + MYNAME + '-' + 'c';
style_c.textContent =
'section div.css-175oi2r.r-f8sm7e.r-13qz1uu.r-1ye8kvj' +
'{max-width: 600px;}';
sm = muts;
document.head.appendChild(style_a);
document.head.appendChild(style_b);
document.head.appendChild(style_c);
muts = sm;
}
for (let e of elms) {
let d, dd, dg, dgi, spdgi, da, ds;
d = e.querySelector(':scope>div>div.r-1hycxz', ':scope>div>div.r-1jocfgc');
if (d != null) {
dd = d.querySelector('div.r-aqfbo4.r-6gpygo.r-15ysp7h'); // null対策
dg = d.querySelector('div[data-testid="google_sign_in_container"]');
dgi = d.querySelector(':scope div[data-testid="google_sign_in_container"] iframe[id^="gsi"]');
da = d.querySelector('button[data-testid="apple_sign_in_button"]');
ds = d.querySelector('a[href="/i/flow/signup"]');
}
if (dgi) spdgi = dgi.parentNode.parentNode;
sm = muts;
if (dd) dd.style.width = '290px';
if (dg) dg.style.width = '260px';
if (dgi) dgi.style.left = '-20px';
if (spdgi) spdgi.style.setProperty('clip-path', 'inset(0 round 20px)');
if (da) da.style.width = '260px';
if (ds) ds.style.width = '260px';
if (d != null) d.style.width = '290px';
e.style.width = '290px'; // 350px
muts = sm;
}
}
function chngBGC() {
let body = document.getElementsByTagName('body')[0];
if (/\(2[0-9]{2},\s*2[0-9]{2},\s*2[0-9]{2}/i.test(body.style.backgroundColor)) {
let time_l = document.querySelector('main div.css-175oi2r.r-14lw9ot.r-f8sm7e');
let float_b = document.querySelector('main div.r-1e5uvyk.r-6026j');
let float_b_m = document.querySelector('div#layers div.r-1e5uvyk.r-6026j[data-testid="TopNavBar"]');
let search_b = document.querySelector('main div.r-aqfbo4.r-15ysp7h.r-1xcajam');
let sm = muts;
body.style.backgroundColor = 'rgb(253, 253, 245)';
if (time_l != null) time_l.style.backgroundColor = 'rgb(253, 253, 245)';
if (float_b != null) float_b.style.backgroundColor = 'rgba(253, 253, 245, 0.85)';
if (float_b_m != null) float_b_m.style.backgroundColor = 'rgba(253, 253, 245, 0.85)';
if (search_b != null) search_b.style.backgroundColor = 'rgb(253, 253, 245)';
muts = sm;
}
}
function hidePromo() {
let elms = document.querySelectorAll(SEL_HP);
let elms_2 = document.querySelectorAll(SEL_HP_2);
let elms_3 = document.querySelectorAll(SEL_HP_3);
let elms_4 = document.querySelectorAll(SEL_HP_4);
let sm; // Temp.
for (let e of elms) {
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
if (!xpe) xpe = e.closest('div.css-175oi2r.r-1adg3ll.r-1ny4l3l'); // def-ja, def-en, ble-ja, ble-en
if (!xpe) xpe = e.closest('div.css-175oi2r.r-1ny4l3l[data-testid="UserCell"]'); // def-ja, def-en, ?, ble-en
sm = muts;
if (xpe) xpe.style.setProperty('display', 'none'); // Right column のおすすめユーザー'
muts = sm;
}
for (let e of elms_2) {
if (!REGEX_HP.test(e.textContent)) continue;
let xpe = e.closest('div.css-175oi2r.r-1adg3ll.r-1ny4l3l');
sm = muts;
xpe.style.setProperty('display', 'none');
muts = sm;
}
for (let e of elms_3) {
if (e.textContent != 'Ad') continue;
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
sm = muts;
xpe.style.setProperty('display', 'none');
muts = sm;
}
for (let e of elms_4) {
if (e.textContent != PROMO_2['en'] && e.textContent != PROMO_L_2) continue;
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
sm = muts;
xpe.style.setProperty('display', 'none');
muts = sm;
}
}
function hideWF() {
let sm; // Temp.
if (REGEX_HW.test(document.URL)) {
for (let i = 1; i < 4; i++) {
let elm = document.querySelector('head style.' + 'us-' + MYNAME + '-' + i);
if (elm) document.head.removeChild(elm);
}
return;
}
if (!document.querySelector('head style.' + 'us-' + MYNAME + '-' + 1)) {
sm = muts;
let style = document.createElement('style');
style.className = 'us-' + MYNAME + '-' + 1;
style.textContent =
'main div[data-testid="primaryColumn"] section div[data-testid="cellInnerDiv"]' +
':has(button.css-175oi2r.r-1loqt21.r-o7ynqc.r-6416eg.r-1ny4l3l[data-testid="UserCell"]) ' +
'{display: none;}';
// フォロー, def-ja, def-en, ble-ja, ble-en
document.head.appendChild(style);
muts = sm;
}
if (!document.querySelector('head style.' + 'us-' + MYNAME + '-' + 2)) {
sm = muts;
let style = document.createElement('style');
style.className = 'us-' + MYNAME + '-' + 2;
style.textContent =
'main div[data-testid="primaryColumn"] section div[data-testid="cellInnerDiv"]' +
':has(h2[aria-level="2"][role="heading"]>div>span.css-1jxf684.r-bcqeeo.r-qvutc0) {display: none;}';
// Who to follow, def-ja, def-en, ble-ja, ble-en
document.head.appendChild(style);
muts = sm;
}
if (!document.querySelector('head style.' + 'us-' + MYNAME + '-' + 3)) {
sm = muts;
let style = document.createElement('style');
style.className = 'us-' + MYNAME + '-' + 3;
style.textContent =
'main div[data-testid="primaryColumn"] section div[data-testid="cellInnerDiv"]' +
':has(a[href*="/connect_people?user_id="]) {display: none;}'; // さらに表示
document.head.appendChild(style);
muts = sm;
}
}
function hideDMD() {
let elm = document.querySelector(SEL_HD);
let sm = muts;
if (elm != null) elm.style.setProperty('display', 'none');
muts = sm;
}
function hideGV() {
let elms = document.querySelectorAll(SEL_HG);
let elms_2 = document.querySelectorAll(SEL_HG_2);
for (let e of elms) {
if (
e.getAttribute('aria-label') == GV_L ||
e.getAttribute('aria-label') == SP_L ||
e.getAttribute('aria-label') == SPYLP_L ||
e.getAttribute('aria-label') == GAFP_L
) {
let sm = muts;
e.parentNode.parentNode.style.setProperty('display', 'none');
muts = sm;
}
}
for (let e of elms_2) {
if (e.textContent == GAFP_L || e.textContent == GAF_L || e.textContent == TXP_L) {
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
let sm = muts;
xpe.style.setProperty('display', 'none');
muts = sm;
}
}
}
function fineEgm() {
document.
querySelectorAll(SEL_FE_R + ', ' + SEL_FE_T + ', ' + SEL_FE_L + ', ' + SEL_FE_B).
forEach(function (e) {
let ce = e.querySelector('span:not(.us-' + MYNAME + ')');
let xpe = e.closest('button');
let n = +xpe.getAttribute('aria-label').split(' ')[0];
let ls = '';
if (n) ls = n.toLocaleString('en-US');
let old = e.querySelector(SEL_ADD_SPAN);
let sm = muts;
if (ce && ce.style.display != 'none') { // 0の時も無い
ce.style.setProperty('display', 'none');
}
if (!old) {
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.textContent = ls;
if (ce) span.style.textOverflow = ce.style.textOverflow;
e.appendChild(span);
} else if (old.textContent != ls) {
old.textContent = ls;
if (ce) old.style.textOverflow = ce.style.textOverflow;
}
muts = sm;
});
}
function fineEgmViewDetl() {
let elm = document.querySelector(SEL_FEVD);
if (!elm) return;
let elm_2 = document.querySelector(SEL_FEVD_2);
if (!elm_2) return;
let pelm = elm.parentNode;
let xpelm_2 = elm_2.closest('div.r-1kbdv8c[aria-label][role="group"]'); // fineegm()のさらに上
let n = +/([0-9]+)[^0-9]+$/.exec(xpelm_2.getAttribute('aria-label'))[1];
let ls = n.toLocaleString('en-US');
let old = pelm.querySelector(SEL_ADD_SPAN);
let sm = muts;
if (!old) {
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.textContent = ls;
span.style.textOverflow = elm.style.textOverflow;
elm.style.setProperty('display', 'none');
pelm.appendChild(span);
} else if (old.textContent != ls) {
old.textContent = ls;
old.style.textOverflow = elm.style.textOverflow;
}
muts = sm;
}
function fineEgmViewTL() {
document.querySelectorAll(SEL_FEVT).forEach(function (e) {
let pe = e.parentNode;
let xpe = e.closest('a');
let n = +xpe.getAttribute('aria-label').split(' ')[0];
let ls = n.toLocaleString('en-US');
let old = pe.querySelector(SEL_ADD_SPAN);
let sm = muts;
if (!old) {
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.textContent = ls;
span.style.textOverflow = e.style.textOverflow;
e.style.setProperty('display', 'none');
pe.appendChild(span);
} else if (old.textContent != ls) {
old.textContent = ls;
old.style.textOverflow = e.style.textOverflow;
}
muts = sm;
});
}
function fineEgmPost() {
let elm = document.querySelector(SEL_FEP + ', ' + SEL_FEP_M);
let elm_old = document.querySelector(SEL_ADD_DIV_FEP);
if (!elm) {
if (elm_old) elm_old.parentNode.removeChild(elm_old);
return;
}
if (elm.querySelector('span')) return;
let elms = document.querySelectorAll(SEL_FEP_2);
if (!elms.length) {
if (elm_old) elm_old.parentNode.removeChild(elm_old);
elm.style.setProperty('display', 'inline');
return;
}
let ls = '?';
for (let e of elms) {
let json = JSON.parse(e.textContent);
if (json.mainEntity.additionalName == document.URL.split('/')[3]) {
let n = json.mainEntity.interactionStatistic[2].userInteractionCount;
ls = n.toLocaleString('en-US');
break;
}
}
let sm = muts;
if (!elm_old) {
let div = document.createElement('div');
div.className = 'us-' + MYNAME + '-fep';
div.textContent = ls + ' ' + elm.textContent.split(' ')[1];
div.style.textOverflow = elm.style.textOverflow;
div.style.color = elm.style.color;
elm.style.setProperty('display', 'none');
elm.parentNode.appendChild(div);
} else if (elm_old.textContent.split(' ')[0] != ls) {
elm_old.textContent = ls + ' ' + elm.textContent.split(' ')[1];
elm_old.style.textOverflow = elm.style.textOverflow;
elm_old.style.color = elm.style.color;
}
muts = sm;
}
function isHLSURL(url) {
return (
/^https?:\/\/video\.twimg\.com\/[^?]+\.m3u8?/i.test(url) ||
/^https?:\/\/[^.]+\.video\.pscp\.tv\/[^?]+\.m3u8?/i.test(url)
);
}
function isHLSMaster(text) {
return (
text &&
text.includes('#EXT-X-STREAM-INF') &&
!text.includes('#EXT-X-TARGETDURATION')
);
}
function pickOne(reg, text) {
let matches = [];
const HEAD = text.replace(reg, function (m, p1) {
matches.push([m, p1]);
return '';
});
const L = matches.length;
if (L < 2) return text;
let select = matches[0];
for (let i = 1; i < L; i++) { // 2番目から
select =
(sets.fix_vq != 2 && +select[1] < +matches[i][1]) ||
(sets.fix_vq == 2 && +select[1] > +matches[i][1]) ? matches[i] :
select;
}
return (HEAD + '\n' + select[0]).trim().replace(/(\r?\n)+/g, '\n') + '\n';
}
function twtXHRStateHandler({ target: xhr }) {
if (xhr.readyState === 4) {
const RAW_TEXT = xhr.responseText;
if (isHLSMaster(RAW_TEXT)) {
const REG = /#EXT-X-STREAM-INF.*[^-]BANDWIDTH=(\d+).*\r?\n\/.+$/gm;
const MOD_TEXT = pickOne(REGEX_TXSH, RAW_TEXT);
Object.defineProperties(xhr, {
response: { writable: true },
responseText: { writable: true },
});
xhr.response = xhr.responseText = MOD_TEXT;
}
}
}
function overrideXHROpen() {
orig_xhr_open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
if (isHLSURL(arguments[1])) {
this.addEventListener('readystatechange', twtXHRStateHandler);
}
return orig_xhr_open.apply(this, arguments);
};
console.log(MYNAME + ': XMLHttpRequest.open overriden.');
}
function replDatetime() {
document.
querySelectorAll(
SEL_RD + ', ' + SEL_RD_2 + ', ' + SEL_RD_3 + ', ' + SEL_RD_4 + ', ' + SEL_RD_4M + ', ' + SEL_RD_5
).
forEach(function (e) {
let d = e.getAttribute('datetime');
let df = fmtDate(sets.fmt, new Date(d));
let pe = e.parentNode;
let old = pe.querySelectorAll(SEL_ADD_SPAN);
let sm = muts;
if (!old.length) {
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.setAttribute('datetime', d);
span.setAttribute('local-datetime', df);
span.textContent = df;
e.style.setProperty('display', 'none');
pe.appendChild(span);
} else if (old[0].getAttribute('local-datetime') != df) { // TZ change
old[0].setAttribute('local-datetime', df);
old[0].textContent = df;
}
muts = sm;
});
}
function loop() {
setTimeout(function () {
if (muts) {
muts = null; // 初期値がtrue、変更もしない
if (sets.fmt) replDatetime();
if (sets.bbr) BBReturn();
if (sets.orig_img) origImg();
if (sets.wtl) wideTL();
if (sets.ec_mode) chngBGC();
if (sets.hide_pp) hidePromo();
if (sets.hide_wf) hideWF();
if (sets.hide_dmd) hideDMD();
if (sets.hide_gv) hideGV();
if (sets.fine_egm) {
fineEgm();
fineEgmViewDetl();
fineEgmViewTL();
fineEgmPost();
time_fine_egm = Date.now();
}
} else if (sets.fine_egm == 1 && Date.now() - time_fine_egm > 4000) {
fineEgm();
fineEgmViewDetl();
fineEgmViewTL();
fineEgmPost();
time_fine_egm = Date.now();
}
loop();
}, sets.intl);
}
for (let v in SETS) sets[v] = SETS[v][1];
if (!NO_GUI) initGUI();
if (sets.fix_vq) overrideXHROpen();
observer.observe(document, { childList: true, subtree: true });
loop();
})(); /* END */