|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name YouTube Super Fast Chat
|
3 |
| -// @version 0.60.30 |
| 3 | +// @version 0.60.31 |
4 | 4 | // @license MIT
|
5 | 5 | // @name:ja YouTube スーパーファーストチャット
|
6 | 6 | // @name:zh-TW YouTube 超快聊天
|
|
132 | 132 |
|
133 | 133 | const BOOST_MENU_OPENCHANGED_RENDERING = true;
|
134 | 134 | 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 |
135 | 136 | const PREREQUEST_CONTEXT_MENU_ON_MOUSE_DOWN = true; // require CACHE_SHOW_CONTEXT_MENU_FOR_REOPEN = true
|
136 | 137 | // const FIX_MENU_CAPTURE_SCROLL = true;
|
137 | 138 | const CHAT_MENU_REFIT_ALONG_SCROLLING = 0; // 0 for locking / default; 1 for unlocking only; 2 for unlocking and refit
|
|
575 | 576 | }
|
576 | 577 |
|
577 | 578 | 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 */ |
579 | 580 | }
|
580 | 581 |
|
581 | 582 | yt-live-chat-auto-mod-message-renderer.yt-live-chat-item-list-renderer[whole-message-clickable] #menu.style-scope[class] {
|
|
1029 | 1030 | }
|
1030 | 1031 |
|
1031 | 1032 |
|
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; |
1033 | 1035 |
|
1034 |
| - const _config_ = () => { |
1035 |
| - try { |
1036 |
| - return ytcfg.data_; |
1037 |
| - } catch (e) { } |
1038 |
| - return null; |
1039 |
| - }; |
1040 | 1036 |
|
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) => { |
1042 | 1047 |
|
1043 |
| - // console.log(700) |
| 1048 | + // console.log(700) |
1044 | 1049 |
|
1045 |
| - if (!EXPERIMENT_FLAGS) return; |
| 1050 | + if (!EXPERIMENT_FLAGS) return; |
1046 | 1051 |
|
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) |
1053 | 1057 | }
|
| 1058 | + } |
1054 | 1059 |
|
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 | + } |
1060 | 1065 |
|
1061 |
| - }; |
| 1066 | + }; |
1062 | 1067 |
|
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); |
1071 | 1075 | }
|
1072 | 1076 | }
|
| 1077 | + } |
1073 | 1078 |
|
1074 |
| - window._ytConfigHacks.add((config_) => { |
1075 |
| - uf(config_); |
1076 |
| - }); |
| 1079 | + window._ytConfigHacks.add((config_) => { |
| 1080 | + uf(config_); |
| 1081 | + }); |
1077 | 1082 |
|
1078 |
| - uf(); |
| 1083 | + uf(); |
1079 | 1084 |
|
1080 |
| - })(); |
| 1085 | + })(); |
1081 | 1086 |
|
1082 | 1087 | if (DISABLE_Translation_By_Google) {
|
1083 | 1088 |
|
|
4523 | 4528 |
|
4524 | 4529 | // @property --ticker-rtime
|
4525 | 4530 |
|
4526 |
| - if(typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_; |
| 4531 | + if (typeof isCSSPropertySupported_ === 'boolean') return isCSSPropertySupported_; |
4527 | 4532 | isCSSPropertySupported_ = false;
|
4528 | 4533 |
|
4529 | 4534 | if (typeof CSS !== 'object' || typeof (CSS || 0).registerProperty !== 'function') return false;
|
|
4543 | 4548 | ],
|
4544 | 4549 | {
|
4545 | 4550 | fill: "forwards",
|
4546 |
| - duration: 1000*40, |
| 4551 | + duration: 1000 * 40, |
4547 | 4552 | easing: 'linear'
|
4548 | 4553 | }
|
4549 | 4554 | );
|
|
6718 | 6723 | // https://www.youtube.com/watch?v=oQzFi1NO7io
|
6719 | 6724 |
|
6720 | 6725 |
|
| 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 | + |
6721 | 6787 | }
|
6722 | 6788 |
|
6723 | 6789 |
|
|
0 commit comments