Skip to content

Commit e01c1f2

Browse files
committed
YouTube Super Fast Chat | New Feature
added `NO_ITEM_TAP_FOR_NON_STATIONARY_TAP`
1 parent cde27d2 commit e01c1f2

File tree

1 file changed

+105
-39
lines changed

1 file changed

+105
-39
lines changed

469878-youtube-chat.js

Lines changed: 105 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name YouTube Super Fast Chat
3-
// @version 0.60.30
3+
// @version 0.60.31
44
// @license MIT
55
// @name:ja YouTube スーパーファーストチャット
66
// @name:zh-TW YouTube 超快聊天
@@ -132,6 +132,7 @@
132132

133133
const BOOST_MENU_OPENCHANGED_RENDERING = true;
134134
const FIX_CLICKING_MESSAGE_MENU_DISPLAY_ON_MOUSE_CLICK = true; // click again = close
135+
const NO_ITEM_TAP_FOR_NON_STATIONARY_TAP = true; // dont open the menu (e.g. text message) if cursor is moved or long press
135136
const PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN = true; // require CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true
136137
// const FIX_MENU_CAPTURE_SCROLL = true;
137138
const CHAT_MENU_REFIT_ALONG_SCROLLING = 0; // 0 for locking / default; 1 for unlocking only; 2 for unlocking and refit
@@ -575,7 +576,7 @@
575576
}
576577
577578
yt-live-chat-text-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
578-
pointer-events: none !important;
579+
pointer-events: none !important; /* TO_BE_REVIEWED */
579580
}
580581
581582
yt-live-chat-auto-mod-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
@@ -1029,55 +1030,59 @@
10291030
}
10301031

10311032

1032-
; (ENABLE_FLAGS_MAINTAIN_STABLE_LIST || ENABLE_FLAGS_REUSE_COMPONENTS) && (() => {
1033+
const px2cm = (px) => px * window.devicePixelRatio * 0.026458333;
1034+
const px2mm = (px) => px * window.devicePixelRatio * 0.26458333;
10331035

1034-
const _config_ = () => {
1035-
try {
1036-
return ytcfg.data_;
1037-
} catch (e) { }
1038-
return null;
1039-
};
10401036

1041-
const flagsFn = (EXPERIMENT_FLAGS) => {
1037+
; (ENABLE_FLAGS_MAINTAIN_STABLE_LIST || ENABLE_FLAGS_REUSE_COMPONENTS) && (() => {
1038+
1039+
const _config_ = () => {
1040+
try {
1041+
return ytcfg.data_;
1042+
} catch (e) { }
1043+
return null;
1044+
};
1045+
1046+
const flagsFn = (EXPERIMENT_FLAGS) => {
10421047

1043-
// console.log(700)
1048+
// console.log(700)
10441049

1045-
if (!EXPERIMENT_FLAGS) return;
1050+
if (!EXPERIMENT_FLAGS) return;
10461051

1047-
if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST) {
1048-
if (USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true : true) {
1049-
EXPERIMENT_FLAGS.kevlar_tuner_should_test_maintain_stable_list = true;
1050-
EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list = true;
1051-
// console.log(701)
1052-
}
1052+
if (ENABLE_FLAGS_MAINTAIN_STABLE_LIST) {
1053+
if (USE_MAINTAIN_STABLE_LIST_ONLY_WHEN_KS_FLAG_IS_SET ? EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list === true : true) {
1054+
EXPERIMENT_FLAGS.kevlar_tuner_should_test_maintain_stable_list = true;
1055+
EXPERIMENT_FLAGS.kevlar_should_maintain_stable_list = true;
1056+
// console.log(701)
10531057
}
1058+
}
10541059

1055-
if (ENABLE_FLAGS_REUSE_COMPONENTS) {
1056-
EXPERIMENT_FLAGS.kevlar_tuner_should_test_reuse_components = true;
1057-
EXPERIMENT_FLAGS.kevlar_tuner_should_reuse_components = true;
1058-
// console.log(702);
1059-
}
1060+
if (ENABLE_FLAGS_REUSE_COMPONENTS) {
1061+
EXPERIMENT_FLAGS.kevlar_tuner_should_test_reuse_components = true;
1062+
EXPERIMENT_FLAGS.kevlar_tuner_should_reuse_components = true;
1063+
// console.log(702);
1064+
}
10601065

1061-
};
1066+
};
10621067

1063-
const uf = (config_) => {
1064-
config_ = config_ || _config_();
1065-
if (config_) {
1066-
const { EXPERIMENT_FLAGS, EXPERIMENTS_FORCED_FLAGS } = config_;
1067-
if (EXPERIMENT_FLAGS) {
1068-
flagsFn(EXPERIMENT_FLAGS);
1069-
if (EXPERIMENTS_FORCED_FLAGS) flagsFn(EXPERIMENTS_FORCED_FLAGS);
1070-
}
1068+
const uf = (config_) => {
1069+
config_ = config_ || _config_();
1070+
if (config_) {
1071+
const { EXPERIMENT_FLAGS, EXPERIMENTS_FORCED_FLAGS } = config_;
1072+
if (EXPERIMENT_FLAGS) {
1073+
flagsFn(EXPERIMENT_FLAGS);
1074+
if (EXPERIMENTS_FORCED_FLAGS) flagsFn(EXPERIMENTS_FORCED_FLAGS);
10711075
}
10721076
}
1077+
}
10731078

1074-
window._ytConfigHacks.add((config_) => {
1075-
uf(config_);
1076-
});
1079+
window._ytConfigHacks.add((config_) => {
1080+
uf(config_);
1081+
});
10771082

1078-
uf();
1083+
uf();
10791084

1080-
})();
1085+
})();
10811086

10821087
if (DISABLE_Translation_By_Google) {
10831088

@@ -4523,7 +4528,7 @@
45234528

45244529
// @property --ticker-rtime
45254530

4526-
if(typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_;
4531+
if (typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_;
45274532
isCSSPropertySupported_ = false;
45284533

45294534
if (typeof CSS !== 'object' || typeof (CSS || 0).registerProperty !== 'function') return false;
@@ -4543,7 +4548,7 @@
45434548
],
45444549
{
45454550
fill: "forwards",
4546-
duration: 1000*40,
4551+
duration: 1000 * 40,
45474552
easing: 'linear'
45484553
}
45494554
);
@@ -6718,6 +6723,67 @@
67186723
// https://www.youtube.com/watch?v=oQzFi1NO7io
67196724

67206725

6726+
}
6727+
6728+
if (NO_ITEM_TAP_FOR_NON_STATIONARY_TAP) {
6729+
let targetElementCntWR = null;
6730+
let _e0 = null;
6731+
document.addEventListener('mousedown', (e) => {
6732+
if (!e || !e.isTrusted) return;
6733+
let element = e.target;
6734+
for (; element instanceof HTMLElement; element = element.parentNode) {
6735+
if (element.is) break;
6736+
}
6737+
if (!element || !element.is) return;
6738+
const cnt = insp(element);
6739+
if (typeof cnt.onItemTap === 'function') {
6740+
cnt._onItemTap_isNonStationary = 0;
6741+
const cProto = getProto(element);
6742+
if (!cProto.onItemTap366 && typeof cProto.onItemTap === 'function' && cProto.onItemTap.length === 1) {
6743+
cProto.onItemTap366 = cProto.onItemTap;
6744+
cProto.onItemTap = function (a) {
6745+
const t = this._onItemTap_isNonStationary;
6746+
this._onItemTap_isNonStationary = 0;
6747+
if (t > Date.now()) return;
6748+
return this.onItemTap366.apply(this, arguments)
6749+
}
6750+
}
6751+
_e0 = e;
6752+
targetElementCntWR = mWeakRef(cnt);
6753+
} else {
6754+
_e0 = null;
6755+
targetElementCntWR = null;
6756+
}
6757+
}, { capture: true, passive: true });
6758+
6759+
document.addEventListener('mouseup', (e) => {
6760+
if (!e || !e.isTrusted) return;
6761+
const e0 = _e0;
6762+
_e0 = null;
6763+
if (!e0) return;
6764+
const cnt = kRef(targetElementCntWR);
6765+
targetElementCntWR = null;
6766+
if (!cnt) return;
6767+
if (e.timeStamp - e0.timeStamp > 280) {
6768+
cnt._onItemTap_isNonStationary = Date.now() + 40;
6769+
} else if ((window.getSelection() + "").trim().replace(/[\u2000-\u200a\u202f\u2800\u200B\u200C\u200D\uFEFF]+/g, '').length >= 1) {
6770+
cnt._onItemTap_isNonStationary = Date.now() + 40;
6771+
} else {
6772+
const dx = e.clientX - e0.clientX;
6773+
const dy = e.clientY - e0.clientY;
6774+
const dd = Math.sqrt(dx * dx + dy * dy);
6775+
const ddmm = px2mm(dd);
6776+
if (ddmm > 1.0) {
6777+
cnt._onItemTap_isNonStationary = Date.now() + 40;
6778+
} else {
6779+
cnt._onItemTap_isNonStationary = 0;
6780+
}
6781+
}
6782+
}, { capture: true, passive: true });
6783+
6784+
6785+
6786+
67216787
}
67226788

67236789

0 commit comments

Comments
 (0)