// ==UserScript==
// @name Show date normally on Twitter
// @name:ja Twitter で日時を通常の表記に
// @name:ko 트위터에서 날짜와 시간을 일반 표기법으로 변경
// @name:zh-CN 在推特上显示正常的日期和时间
// @name:zh-TW 在推特上顯示正常的日期和時間
// @namespace https://gf.qytechs.cn/en/scripts/462064-show-date-normally-on-twitter
// @version 1.17.0
// @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/*
// @require https://update.gf.qytechs.cn/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 NOGUI = false;
// ////////////////////////////////// //
// ///////// Default valuse ///////// //
// Blue bird returns
const BBR = false;
// Replace with orig images(wasted traffic occurs)
const ORIGI = false;
// Slightly wider TL
const WTL = false;
// Eye Care Mode at default background
const ECMODE = true;
// Hide promotions
const HPP = true;
// Hide Who to follow
const HWTF = true;
// Hide DM drawer
const HDMD = true;
// Hide Get Verified
const HGV = true;
// Fix videos quality
// 1. maximum
// 2. minimum
// 0. Do nothing
const FVQ = 1;
// Date formats
// 1. 31.12.70 23:59
// 2. 31.12.70 23:59:59
// 3. 31.12.70(Th) 23:59
// 4. 31.12.70(Th) 23:59:59
//
// 5. 70/12/31 23:59
// 6. 70/12/31 23:59:59
// 7. 70/12/31(Th) 23:59
// 8. 70/12/31(Th) 23:59:59 [ye/mo/da(we) ho:mi:se]
//
// 9. 70-12/31 23:59
// 10. 70-12/31 23:59'59
// 11. 70-12/31(Th) 23:59
// 12. 70-12/31(Th) 23:59'59
//
// 13. M59-12-31 23:59
// 14. M59-12-31 23:59:59
// 15. M59-12-31(Th) 23:59
// 16. M59-12-31(Th) 23:59:59
//
// 0. Do nothing
const FMT = 7;
// Loop interval(ms)
const INTL = 800;
// ////////////////////////////////// //
const MYNAME = 'sdnt1170';
const originalXHROpen = XMLHttpRequest.prototype.open;
let s_mutations = true;
let observer = new MutationObserver(function (mutations) {
s_mutations = mutations;
// 概念だけが複製される。個々の要素は参照渡し…
// 元がconstであっても、要素は変更される……
});
let bbr, origi, wtl, ecmode, hpp, hwtf, hdmd, hgv, fvq, fmt, intl;
let dalg;
function makeDialog() {
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 = '440px';
dalg.style.width = '460px';
dalg.style.paddingLeft = '2px';
dalg.style.paddingRight = '2px';
dalg.style.position = 'fixed';
dalg.style.right = '8px';
dalg.style.top = '8px';
dalg.style.zIndex = '2147483647';
let html =
'<span style="all: initial; font-size: 120%; line-height: 210%">' +
GM_info.script.name +
' ' +
GM_info.script.version +
' ' +
'Settings' +
'</span><br />\n' +
'<input type="radio" name="fmt" value="1" class="top_r" />31.12.70 23:59' +
' ' +
' ' +
'<input type="radio" name="fmt" value="2" class="top_r" />31.12.70 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="3" class="mid_r" />31.12.70(Th) 23:59' +
' ' +
'<input type="radio" name="fmt" value="4" class="mid_r" />31.12.70(Th) 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="5" class="mid_r" />70/12/31 23:59' +
' ' +
'<input type="radio" name="fmt" value="6" class="mid_r" />70/12/31 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="7" class="mid_r" />70/12/31(Th) 23:59' +
' ' +
'<input type="radio" name="fmt" value="8" class="mid_r" />70/12/31(Th) 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="9" class="mid_r" />70-12/31 23:59' +
' ' +
'<input type="radio" name="fmt" value="10" class="mid_r" />70-12/31 23:59\'59<br />\n' +
'<input type="radio" name="fmt" value="11" class="mid_r" />70-12/31(Th) 23:59' +
' ' +
'<input type="radio" name="fmt" value="12" class="mid_r" />70-12/31(Th) 23:59\'59<br />\n' +
'<input type="radio" name="fmt" value="13" class="mid_r" />M59-12-31 23:59' +
' ' +
'<input type="radio" name="fmt" value="14" class="mid_r" />M59-12-31 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="15" class="mid_r" />M59-12-31(Th) 23:59' +
' ' +
'<input type="radio" name="fmt" value="16" class="mid_r" />M59-12-31(Th) 23:59:59<br />\n' +
'<input type="radio" name="fmt" value="0" class="btm_r" />Do nothing<br />\n' +
'<input type="checkbox" name="bbr" class="top_c" />BB returns' +
' ' +
'<input type="checkbox" name="origi" class="mid_c" />Replace with orig images*<br />\n' +
'<input type="checkbox" name="wtl" class="mid_c" />Widen slightly TL' +
' ' +
'<input type="checkbox" name="ecmode" class="btm_c" />Eye Care Mode at default BG<br />\n' +
'<input type="checkbox" name="hpp" class="top_c" />Hide promotions' +
' ' +
'<input type="checkbox" name="hwtf" class="mid_c" />Hide Who to follow<br />\n' +
'<input type="checkbox" name="hdmd" class="mid_c" />Hide DM drawer' +
' ' +
'<input type="checkbox" name="hgv" class="btm_c" />Hide Get Verified<br />\n' +
'<input type="radio" name="fvq" value="1" class="top_r" />at maximum video quality**' +
' ' +
'<input type="radio" name="fvq" value="2" class="top_r" />at minimum video quality<br />\n' +
'<input type="radio" name="fvq" value="0" class="btm_r" />Do nothing<br />\n' +
'<span style="all: initial; font-size: 100%">' +
'Loop interval(ms)** ' +
'</span><input type="text" name="intl" size="10" class="top_t" /><br />\n' +
'<span style="all: initial; font-size: 100%; line-height: 200%">' +
'*wasted traffic occurs **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';
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_t')) {
e.style.all = 'initial';
e.style.backgroundColor = 'rgb(255, 255, 255)';
e.style.fontFamily = 'monospace';
e.style.fontSize = '100%';
e.style.marginLeft = '1px';
e.style.marginRight = '1px';
e.style.marginTop = '8px';
e.style.marginBottom = '0px';
e.style.paddingLeft = '1px';
e.style.paddingRight = '1px';
e.style.paddingTop = '1px';
e.style.paddingBottom = '1px';
}
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 = '10px';
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 () {
dalg.querySelector('input[name="bbr"]').checked = BBR;
dalg.querySelector('input[name="origi"]').checked = ORIGI;
dalg.querySelector('input[name="fmt"][value="' + FMT + '"]').checked = true;
dalg.querySelector('input[name="wtl"]').checked = WTL;
dalg.querySelector('input[name="ecmode"]').checked = ECMODE;
dalg.querySelector('input[name="hpp"]').checked = HPP;
dalg.querySelector('input[name="hwtf"]').checked = HWTF;
dalg.querySelector('input[name="hdmd"]').checked = HDMD;
dalg.querySelector('input[name="hgv"]').checked = HGV;
dalg.querySelector('input[name="fvq"][value="' + FVQ + '"]').checked = true;
dalg.querySelector('input[name="intl"]').value = INTL;
},
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 () {
bbr = dalg.querySelector('input[name="bbr"]').checked;
origi = dalg.querySelector('input[name="origi"]').checked;
for (let e of dalg.querySelectorAll('input[name="fmt"]')) {
if (e.checked) {
fmt = +e.value;
break;
}
}
wtl = dalg.querySelector('input[name="wtl"]').checked;
ecmode = dalg.querySelector('input[name="ecmode"]').checked;
hpp = dalg.querySelector('input[name="hpp"]').checked;
hwtf = dalg.querySelector('input[name="hwtf"]').checked;
hdmd = dalg.querySelector('input[name="hdmd"]').checked;
hgv = dalg.querySelector('input[name="hgv"]').checked;
for (let e of dalg.querySelectorAll('input[name="fvq"]')) {
if (e.checked) {
fvq = +e.value;
break;
}
}
intl = +dalg.querySelector('input[name="intl"]').value;
GM_setValue('bbr', bbr);
GM_setValue('origi', origi);
GM_setValue('fmt', fmt);
GM_setValue('wtl', wtl);
GM_setValue('ecmode', ecmode);
GM_setValue('hpp', hpp);
GM_setValue('hwtf', hwtf);
GM_setValue('hdmd', hdmd);
GM_setValue('hgv', hgv);
GM_setValue('fvq', fvq);
GM_setValue('intl', intl);
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() {
if (GM_getValue('bbr') === undefined) {
GM_setValue('bbr', BBR);
} else {
bbr = GM_getValue('bbr');
}
if (GM_getValue('origi') === undefined) {
GM_setValue('origi', ORIGI);
} else {
origi = GM_getValue('origi');
}
if (GM_getValue('fmt') === undefined) {
GM_setValue('fmt', FMT);
} else {
fmt = GM_getValue('fmt');
}
if (GM_getValue('wtl') === undefined) {
GM_setValue('wtl', WTL);
} else {
wtl = GM_getValue('wtl');
}
if (GM_getValue('ecmode') === undefined) {
GM_setValue('ecmode', ECMODE);
} else {
ecmode = GM_getValue('ecmode');
}
if (GM_getValue('hpp') === undefined) {
GM_setValue('hpp', HPP);
} else {
hpp = GM_getValue('hpp');
}
if (GM_getValue('hwtf') === undefined) {
GM_setValue('hwtf', HWTF);
} else {
hwtf = GM_getValue('hwtf');
}
if (GM_getValue('hdmd') === undefined) {
GM_setValue('hdmd', HDMD);
} else {
hdmd = GM_getValue('hdmd');
}
if (GM_getValue('hgv') === undefined) {
GM_setValue('hgv', HGV);
} else {
hgv = GM_getValue('hgv');
}
if (GM_getValue('fvq') === undefined) {
GM_setValue('fvq', FVQ);
} else {
fvq = GM_getValue('fvq');
}
if (GM_getValue('intl') === undefined) {
GM_setValue('intl', INTL);
} else {
intl = GM_getValue('intl');
}
dalg = makeDialog();
makeFunc(dalg);
document.body.appendChild(dalg);
GM_registerMenuCommand('Settings', function () {
if (dalg.style.display == 'none') {
dalg.querySelector('input[name="bbr"]').checked = bbr;
dalg.querySelector('input[name="origi"]').checked = origi;
dalg.querySelector('input[name="fmt"][value="' + fmt + '"]').checked = true;
dalg.querySelector('input[name="wtl"]').checked = wtl;
dalg.querySelector('input[name="ecmode"]').checked = ecmode;
dalg.querySelector('input[name="hpp"]').checked = hpp;
dalg.querySelector('input[name="hwtf"]').checked = hwtf;
dalg.querySelector('input[name="hdmd"]').checked = hdmd;
dalg.querySelector('input[name="hgv"]').checked = hgv;
dalg.querySelector('input[name="fvq"][value="' + fvq + '"]').checked = true;
dalg.querySelector('input[name="intl"]').value = intl;
dalg.style.display = 'block';
}
});
}
function datef(date, f) {
let l = document.documentElement.getAttribute('lang');
let week_l =
l == 'ja' ? ['日', '月', '火', '水', '木', '金', '土'] :
l == 'ko' ? ['일', '월', '화', '수', '목', '금', '토'] :
l == 'zh-Hant' ? ['日', '一', '二', '三', '四', '五', '六'] :
l == 'zh' ? ['日', '一', '二', '三', '四', '五', '六'] :
l == 'ru' ? ['ВС', 'ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ'] :
l == 'de' ? ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'] :
l == 'it' ? ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'] :
l == 'fr' ? ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'] :
l == 'pt' ? ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'] : // Add your language
['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
let ye, ym, mo, da, we, ho, mi, se;
ye = date.getFullYear().toString().slice(-2);
ym = date.getFullYear() - 1911;
mo = ('0' + (date.getMonth() + 1)).slice(-2);
da = ('0' + date.getDate()).slice(-2);
we = week_l[date.getDay()];
ho = ('0' + date.getHours()).slice(-2);
mi = ('0' + date.getMinutes()).slice(-2);
se = ('0' + date.getSeconds()).slice(-2);
return f == 1 ? da+'.'+mo+'.'+ye+' '+ho+':'+mi :
f == 2 ? da+'.'+mo+'.'+ye+' '+ho+':'+mi+':'+se :
f == 3 ? da+'.'+mo+'.'+ye+'('+we+') '+ho+':'+mi :
f == 4 ? da+'.'+mo+'.'+ye+'('+we+') '+ho+':'+mi+':'+se :
f == 5 ? ye+'/'+mo+'/'+da+' '+ho+':'+mi :
f == 6 ? ye+'/'+mo+'/'+da+' '+ho+':'+mi+':'+se :
f == 7 ? ye+'/'+mo+'/'+da+'('+we+') '+ho+':'+mi :
f == 8 ? ye+'/'+mo+'/'+da+'('+we+') '+ho+':'+mi+':'+se :
f == 9 ? ye+'-'+mo+'/'+da+' '+ho+':'+mi :
f == 10 ? ye+'-'+mo+'/'+da+' '+ho+':'+mi+"'"+se :
f == 11 ? ye+'-'+mo+'/'+da+'('+we+') '+ho+':'+mi :
f == 12 ? ye+'-'+mo+'/'+da+'('+we+') '+ho+':'+mi+"'"+se :
f == 13 ? 'M'+ym+'-'+mo+'-'+da+' '+ho+':'+mi :
f == 14 ? 'M'+ym+'-'+mo+'-'+da+' '+ho+':'+mi+":"+se :
f == 15 ? 'M'+ym+'-'+mo+'-'+da+'('+we+') '+ho+':'+mi :
f == 16 ? 'M'+ym+'-'+mo+'-'+da+'('+we+') '+ho+':'+mi+":"+se :
ye+'/'+mo+'/'+da+'('+we+') '+ho+':'+mi+':'+se;
}
function bbreturn() {
const SEL_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_H = 'header[role="banner"] h1[role="heading"] g path'; // ホーム
const SEL_V = 'header[role="banner"] nav g path'; // 認証済み
const SEL_L =
'div[role="dialog"] div[aria-labelledby="modal-header"] svg.r-lrvibr path'; // ログイン
const SEL_T = 'div#react-root main svg.r-lrvibr path'; // トップ
let elms = document.querySelectorAll(
SEL_ID + ', ' + SEL_H + ', ' + SEL_V + ', ' + SEL_L + ', ' + SEL_T,
);
let ss; // Temp.
for (let e of elms) {
const D_X = '^M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99';
const REGEX = new RegExp(D_X, 'i');
const D_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 D_FILL_N = 'none';
const D_FILL_LB = '#1da1f2ff';
const D_FILL_DB = '#1d9bf0ff';
const D_S = 'currentColor';
const D_SW = '2';
if (REGEX.test(e.getAttribute('d'))) {
if (e.closest('header[role="banner"] nav')) {
ss = s_mutations;
e.setAttribute('d', D_BB);
e.setAttribute('fill', D_FILL_N);
e.setAttribute('stroke', D_S);
e.setAttribute('stroke-width', D_SW);
s_mutations = ss;
} else if (
e.closest('div#placeholder[aria-label="Loading…"]') ||
e.closest('svg[id^="loading-x-anim-"]')
) {
ss = s_mutations;
e.setAttribute('d', D_BB);
e.setAttribute('fill', D_FILL_LB);
s_mutations = ss;
} else {
ss = s_mutations;
e.setAttribute('d', D_BB);
e.setAttribute('fill', D_FILL_DB);
s_mutations = ss;
}
}
}
let elm = document.querySelector('head link[rel="shortcut icon"]');
let elm_2 = document.querySelector('head link[rel="apple-touch-icon"]');
let title = document.title;
ss = s_mutations;
if (
!/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 (
!/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 (
/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 (title != rt) document.title = rt;
s_mutations = ss;
}
function origimg() {
const SEL_D = 'div[style*="background-image:"]';
const SEL_I = 'img';
let elms = document.querySelectorAll(SEL_D + ', ' + SEL_I);
for (let e of elms) {
let regex =
/^(.+pbs\.twimg\.com\/[^?]+\?format=\w+)(&|&)(name=)(\w+)([")]*)$/;
let ss; // Temp.
if (/div/i.test(e.tagName)) {
let r = regex.exec(e.style.backgroundImage);
if (r && r[4] != 'orig') {
ss = s_mutations;
e.style.backgroundImage = r[1] + r[2] + r[3] + 'orig' + r[5];
s_mutations = ss;
continue;
}
continue;
}
let r = regex.exec(e.getAttribute('src'));
if (r && r[4] != 'orig') {
ss = s_mutations;
e.setAttribute('src', r[1] + r[2] + r[3] + 'orig' + r[5]);
s_mutations = ss;
continue;
}
}
}
function widetl() {
let l = document.documentElement.getAttribute('lang');
let sd_l =
l == 'ja' ? 'セクションの詳細' :
l == 'ko' ? '섹션 세부사항' :
l == 'zh-Hant' ? '區段詳細資料' :
l == 'zh' ? '板块详情' :
l == 'ru' ? 'Сведения о разделе' :
l == 'de' ? 'Details zum Abschnitt' :
l == 'it' ? 'Dettagli della sezione' :
l == 'fr' ? 'Détails de la section' :
l == 'pt' ? 'Detalhes da seção' : // Add your language
'Section details';
let elms = document.querySelectorAll('div.r-1ye8kvj');
let elms_2 = document.querySelectorAll('div.css-175oi2r.r-o96wvk');
let elms_3 = document.querySelectorAll('div.css-175oi2r.r-1hycxz');
let elms_4 = document.querySelectorAll(
'section.r-1ye8kvj.r-jxzhtn[aria-label="' + sd_l + '"]',
);
let ss = s_mutations;
for (let e of elms) {
if (e.closest('div[role="dialog"]')) continue;
e.style.maxWidth = '650px'; // 600px
}
for (let e of elms_2) {
e.style.width = '250px'; // 275px
}
for (let e of elms_3) {
e.style.width = '315px'; // 350px
}
for (let e of elms_4) {
e.style.maxWidth = '560px'; // 600px, DM
}
s_mutations = ss;
}
function chgbgc() {
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 tl, fb, sb;
tl = document.querySelector('main div.r-jxzhtn.r-1ljd8xs');
fb = document.querySelector('main div.r-1e5uvyk.r-6026j');
sb = document.querySelector('main div.r-aqfbo4.r-15ysp7h.r-1xcajam');
let ss = s_mutations;
body.style.backgroundColor = 'rgb(253, 253, 245)';
if (tl != null) tl.style.backgroundColor = 'rgb(253, 253, 245)';
if (fb != null) fb.style.backgroundColor = 'rgba(253, 253, 245, 0.85)';
if (sb != null) sb.style.backgroundColor = 'rgb(253, 253, 245)';
s_mutations = ss;
}
}
function hidepromo() {
const SEL =
'svg.r-4qtqp9.r-yyyyoo.r-1q142lx.r-ip8ujx.r-1d4mawv.r-dnmrzs.r-bnwqim.r-1plcrui.r-lrvibr';
const SEL_2 =
'main div[data-testid="primaryColumn"] section article ' +
'span.css-1qaijid.r-bcqeeo.r-qvutc0.r-poiln3';
const SEL_3 =
'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
let elms = document.querySelectorAll(SEL);
let elms_2 = document.querySelectorAll(SEL_2);
let elms_3 = document.querySelectorAll(SEL_3);
let ss; // 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
ss = s_mutations;
if (xpe) xpe.style.setProperty('display', 'none'); // Right column のおすすめユーザー'
s_mutations = ss;
}
for (let e of elms_2) {
if (e.textContent != 'Ad') continue;
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
for (let e of elms_3) {
let l = document.documentElement.getAttribute('lang');
let promo = 'Promoted Post';
let promo_l =
l == 'ja' ? 'プロモポスト' :
l == 'ko' ? 'Promoted Post' :
l == 'zh-Hant' ? '推廣貼文' :
l == 'zh' ? 'Promoted Post' :
l == 'ru' ? 'Promoted Post' :
l == 'de' ? 'Gesponserter Post' :
l == 'it' ? 'Promoted Post' :
l == 'fr' ? 'Promoted Post' :
l == 'pt' ? 'Post promovido' : // Add your language
'Promoted Post';
if (e.textContent != promo) {
if (e.textContent != promo_l) continue;
}
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
}
function hidewtf() {
const SEL =
'main div[data-testid="primaryColumn"] section ' +
'div.css-175oi2r.r-1ny4l3l.r-ymttw5.r-1f1sjgu.r-o7ynqc.r-6416eg[data-testid="UserCell"]';
// def-ja, def-en, ble-ja, ble-en
const SEL_2 =
'main div[data-testid="primaryColumn"] section span.css-1qaijid.r-bcqeeo.r-qvutc0';
// Label def-ja, def-en, ble-ja, ble-en
const SEL_3 =
'main div[data-testid="primaryColumn"] section a[href*="/connect_people?user_id="]'; // さらに表示
let elms = document.querySelectorAll(SEL);
let elms_2 = document.querySelectorAll(SEL_2);
let elms_3 = document.querySelectorAll(SEL_3);
let ss; // Temp.
let r =
'^[^:]+://[^/]+/$|' +
'^[^:]+://[^/]+/(' +
'compose|' + // pop up
'messages|' +
'search-advanced|' +
'explore|' + // no pop up WTFのみ不要
'home|' + // WTFも要?
'notifications|' +
'search|' + // WTFのみ不要
'i/display|' + // pop up
'i/twitter_blue_sign_up|' +
'i/circles|' +
'i/flow|' +
'i/keyboard_shortcuts|' +
'i/verified-orgs-signup|' + // 追加
'i/verified-choose|' + // 追加
'i/premium_sign_up|' + // 追加
'i/connect_people|' + // no pop up
'i/topics|' +
'[^/]+/followers|' + // no pop up
'[^/]+/following|' +
'[^/]+/lists|' +
'[^/]+/status/|' + // WTFのみ不要
'[^/]+/topics|' +
'[^/]+/creator-subscriptions|' + // 追加
'[^/]+/superfollows|' + // 追加
'[^/]+/verified_followers' + // 追加
')';
if (new RegExp(r, 'i').test(document.URL)) return;
for (let e of elms) {
let xpe = e.closest('main section div[data-testid="cellInnerDiv"]');
ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
for (let e of elms_2) {
let l = document.documentElement.getAttribute('lang');
let wtf = 'Who to follow';
let wtf_l =
l == 'ja' ? 'おすすめユーザー' :
l == 'ko' ? '팔로우 추천' :
l == 'zh-Hant' ? '跟隨誰' :
l == 'zh' ? '推荐关注' :
l == 'ru' ? 'Кого читать' :
l == 'de' ? 'Wem folgen' :
l == 'it' ? 'Chi seguire' :
l == 'fr' ? 'Qui suivre' :
l == 'pt' ? 'Quem seguir' : // Add your language
'Who to follow';
if (e.textContent != wtf) {
if (e.textContent != wtf_l) continue;
}
let xpe = e.closest('main section div[data-testid="cellInnerDiv"]');
ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
for (let e of elms_3) {
let xpe = e.closest('main section div[data-testid="cellInnerDiv"]');
ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
}
function hidedmd() {
const SEL = 'div[data-testid="DMDrawer"]';
let elm = document.querySelector(SEL);
let ss = s_mutations;
if (elm != null) elm.style.setProperty('display', 'none');
s_mutations = ss;
}
function hidegv() {
const SEL = 'aside.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-ymttw5.r-1f1sjgu';
const SEL_2 =
'main section div[data-testid="cellInnerDiv"] h1[role="heading"] span.css-1qaijid.r-bcqeeo.r-qvutc0';
// def-ja, def-en, ble-ja, ble-en
let elms = document.querySelectorAll(SEL);
let elms_2 = document.querySelectorAll(SEL_2);
let l = document.documentElement.getAttribute('lang');
for (let e of elms) {
let gv_l =
l == 'ja' ? '認証を受ける' :
l == 'ko' ? '인증 받기' :
l == 'zh-Hant' ? '獲得認證' :
l == 'zh' ? '获得认证' :
l == 'ru' ? 'Подтвердить подлинность' :
l == 'de' ? 'Lass dich verifizieren' :
l == 'it' ? 'Ottieni la verifica' :
l == 'fr' ? 'Obtenez la certification' :
l == 'pt' ? 'Obter verificação' : // Add your language
'Get Verified';
let sp_l =
l == 'ja' ? 'プレミアムにサブスクライブ' :
l == 'ko' ? 'Subscribe to Premium' :
l == 'zh-Hant' ? '訂閱 Premium' :
l == 'zh' ? 'Subscribe to Premium' :
l == 'ru' ? 'Subscribe to Premium' :
l == 'de' ? 'Premium abonnieren' :
l == 'it' ? 'Subscribe to Premium' :
l == 'fr' ? 'Subscribe to Premium' :
l == 'pt' ? 'Assine o Premium' : // Add your language
'Subscribe to Premium';
let spylp_l =
l == 'ja' ? '長いポストを作成するには、プレミアムにサブスクライブしてください' :
l == 'ko' ? 'Premium을 구독하고 나만의 긴 게시물을 작성해 보세요' :
l == 'zh-Hant' ? '訂閱 Premium 以撰寫你自己的更長貼文' :
l == 'zh' ? '订阅 Premium,撰写自己的长帖' :
l == 'ru' ? 'Подпишитесь на Premium, чтобы писать собственные длинные посты' :
l == 'de' ? 'Abonniere Premium, wenn du deine eigenen längeren Posts schreiben möchtest' :
l == 'it' ? 'Per scrivere post più lunghi, abbonati a Premium' :
l == 'fr' ? 'Abonnez-vous à Premium pour écrire vos propres posts plus longs.' :
l == 'pt' ? 'Assine o Premium para escrever posts mais longos' : // Add your language
'Subscribe to Premium to write your own longer posts';
if (
e.getAttribute('aria-label') == gv_l ||
e.getAttribute('aria-label') == sp_l ||
e.getAttribute('aria-label') == spylp_l
) {
let ss = s_mutations;
e.parentNode.style.setProperty('display', 'none');
s_mutations = ss;
}
}
for (let e of elms_2) {
let gaf_l =
l == 'ja' ? '広告をなくす' :
l == 'ko' ? 'Go ad free' :
l == 'zh-Hant' ? 'Go ad free' :
l == 'zh' ? 'Go ad free' :
l == 'ru' ? 'Go ad free' :
l == 'de' ? 'Go ad free' :
l == 'it' ? 'Go ad free' :
l == 'fr' ? 'Go ad free' :
l == 'pt' ? 'Go ad free' : // Add your language
'Go ad free';
let txp_l =
l == 'ja' ? 'TweetDeckはX Proになりました' :
l == 'ko' ? 'TweetDeck is now X Pro' :
l == 'zh-Hant' ? 'TweetDeck is now X Pro' :
l == 'zh' ? 'TweetDeck is now X Pro' :
l == 'ru' ? 'TweetDeck is now X Pro' :
l == 'de' ? 'TweetDeck is now X Pro' :
l == 'it' ? 'TweetDeck is now X Pro' :
l == 'fr' ? 'TweetDeck is now X Pro' :
l == 'pt' ? 'TweetDeck is now X Pro' : // Add your language
'TweetDeck is now X Pro';
if (e.textContent == gaf_l || e.textContent == txp_l) {
let xpe = e.closest('div[data-testid="cellInnerDiv"]');
let ss = s_mutations;
xpe.style.setProperty('display', 'none');
s_mutations = ss;
}
}
}
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) {
const 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 =
(fvq != 2 && +select[1] < +matches[i][1]) ||
(fvq == 2 && +select[1] > +matches[i][1]) ? matches[i] : select;
}
return (head + '\n' + select[0]).trim().replace(/(\r?\n)+/g, '\n') + '\n';
}
function twXHRStateHandler({ target: xhr }) {
if (xhr.readyState === 4) {
const rawText = xhr.responseText;
if (isHLSMaster(rawText)) {
let reg = /#EXT-X-STREAM-INF.*[^-]BANDWIDTH=(\d+).*\r?\n\/.+$/gm;
let modText = pickone(reg, rawText);
Object.defineProperties(xhr, {
response: { writable: true },
responseText: { writable: true },
});
xhr.response = xhr.responseText = modText;
}
}
}
function overrideXHROpen() {
XMLHttpRequest.prototype.open = function () {
let url = arguments[1];
if (isHLSURL(url)) {
this.addEventListener('readystatechange', twXHRStateHandler);
}
return originalXHROpen.apply(this, arguments);
};
console.log(MYNAME + ': XMLHttpRequest.open overriden.');
}
function repldatetime() {
const SEL =
'main div[data-testid="primaryColumn"] section article time[datetime*=":"]';
const SEL_2 =
'div[aria-labelledby="modal-header"] div[data-testid^="User-Name"] time[datetime]';
const SEL_3 = 'div[aria-labelledby="modal-header"] div[aria-label] time[datetime]';
const SEL_4 =
'main section[aria-labelledby="detail-header"] article div[data-testid^="User-Name"] time[datetime]';
const SEL_5 =
'main section div[data-testid="conversation"] div[aria-label] time[datetime]'; // DM list
document
.querySelectorAll(SEL + ', ' + SEL_2 + ', ' + SEL_3 + ', ' + SEL_4 + ', ' + SEL_5)
.forEach(function (e) {
const SEL_ADD = 'span.us-' + MYNAME;
let d = e.getAttribute('datetime');
let df = datef(new Date(d), fmt);
let span = document.createElement('span');
span.className = 'us-' + MYNAME;
span.setAttribute('datetime', d);
span.setAttribute('local-datetime', df);
span.textContent = df;
let pe = e.parentNode;
let old = pe.querySelectorAll(SEL_ADD);
let ss; // Temp.
if (!old.length) {
ss = s_mutations;
e.style.setProperty('display', 'none');
pe.appendChild(span);
s_mutations = ss;
} else if (old[0].getAttribute('local-datetime') != df) {
// TZ change
ss = s_mutations;
old[0].setAttribute('local-datetime', df);
old[0].textContent = df;
s_mutations = ss;
}
});
}
function loop() {
setTimeout(() => {
if (s_mutations) {
s_mutations = null; // 初期値がtrue、変更もしない
if (bbr) bbreturn();
if (origi) origimg();
if (wtl) widetl();
if (ecmode) chgbgc();
if (hpp) hidepromo();
if (hwtf) hidewtf();
if (hdmd) hidedmd();
if (hgv) hidegv();
if (fmt) repldatetime();
}
loop();
}, intl);
}
bbr = BBR;
origi = ORIGI;
wtl = WTL;
ecmode = ECMODE;
hpp = HPP;
hwtf = HWTF;
hdmd = HDMD;
hgv = HGV;
fvq = FVQ;
fmt = FMT;
intl = INTL;
if (!NOGUI) initgui();
if (fvq) overrideXHROpen();
observer.observe(document, { childList: true, subtree: true });
loop();
})(); /* END */