File tree Expand file tree Collapse file tree 7 files changed +57
-1
lines changed
addons/tw-disable-vibration Expand file tree Collapse file tree 7 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ const addons = [
7878 'tw-straighten-comments' ,
7979 'tw-remove-backpack' ,
8080 'tw-remove-feedback' ,
81+ 'tw-disable-vibration' ,
8182 'tw-disable-cloud-variables' ,
8283 'tw-disable-compiler' ,
8384 'editor-stepping'
Original file line number Diff line number Diff line change 1+ /* generated by pull.js */
2+ const manifest = {
3+ "noTranslations" : true ,
4+ "name" : "Disable vibrations" ,
5+ "description" : "Prevents the vibration and gamepad extensions from causing vibrations." ,
6+ "userscripts" : [
7+ {
8+ "url" : "userscript.js"
9+ }
10+ ] ,
11+ "tags" : [
12+ "danger"
13+ ] ,
14+ "enabledByDefault" : false
15+ } ;
16+ export default manifest ;
Original file line number Diff line number Diff line change 1+ /* generated by pull.js */
2+ import _js from "./userscript.js" ;
3+ export const resources = {
4+ "userscript.js" : _js ,
5+ } ;
Original file line number Diff line number Diff line change 1+ export default async function ( { addon } ) {
2+ if ( navigator . vibrate ) {
3+ const originalVibrate = navigator . vibrate ;
4+ navigator . vibrate = function ( ...args ) {
5+ if ( addon . self . disabled ) {
6+ return originalVibrate . call ( this , ...args ) ;
7+ }
8+ return false ;
9+ } ;
10+ }
11+
12+ if ( typeof GamepadHapticActuator === 'function' && typeof GamepadHapticActuator . prototype . pulse === 'function' ) {
13+ const originalPulse = GamepadHapticActuator . prototype . pulse ;
14+ GamepadHapticActuator . prototype . pulse = function ( ...args ) {
15+ if ( addon . self . disabled ) {
16+ return originalPulse . call ( this , ...args ) ;
17+ }
18+ return Promise . resolve ( false ) ;
19+ } ;
20+ }
21+
22+ if ( typeof GamepadHapticActuator === 'function' && typeof GamepadHapticActuator . prototype . playEffect === 'function' ) {
23+ const originalPlayEffect = GamepadHapticActuator . prototype . playEffect ;
24+ GamepadHapticActuator . prototype . playEffect = function ( ...args ) {
25+ if ( addon . self . disabled ) {
26+ return originalPlayEffect . call ( this , ...args ) ;
27+ }
28+ return Promise . resolve ( 'preempted' ) ;
29+ } ;
30+ }
31+ }
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ import _hide_stage from "../addons/hide-stage/_manifest_entry.js";
7676import _tw_straighten_comments from "../addons/tw-straighten-comments/_manifest_entry.js" ;
7777import _tw_remove_backpack from "../addons/tw-remove-backpack/_manifest_entry.js" ;
7878import _tw_remove_feedback from "../addons/tw-remove-feedback/_manifest_entry.js" ;
79+ import _tw_disable_vibration from "../addons/tw-disable-vibration/_manifest_entry.js" ;
7980import _tw_disable_cloud_variables from "../addons/tw-disable-cloud-variables/_manifest_entry.js" ;
8081import _tw_disable_compiler from "../addons/tw-disable-compiler/_manifest_entry.js" ;
8182import _editor_stepping from "../addons/editor-stepping/_manifest_entry.js" ;
@@ -157,6 +158,7 @@ export default {
157158 "tw-straighten-comments" : _tw_straighten_comments ,
158159 "tw-remove-backpack" : _tw_remove_backpack ,
159160 "tw-remove-feedback" : _tw_remove_feedback ,
161+ "tw-disable-vibration" : _tw_disable_vibration ,
160162 "tw-disable-cloud-variables" : _tw_disable_cloud_variables ,
161163 "tw-disable-compiler" : _tw_disable_compiler ,
162164 "editor-stepping" : _editor_stepping ,
Original file line number Diff line number Diff line change 1- {"commit" :" f41d6de " }
1+ {"commit" :" 965a016 " }
You can’t perform that action at this time.
0 commit comments