Block Orientation Sensor Access

Blocks websites on Safari mobile from accessing iPad's Orientation sensors. (22/2/2024)

  1. // ==UserScript==
  2. // @name Block Orientation Sensor Access
  3. // @namespace Ka0uS
  4. // @version 0.2
  5. // @description Blocks websites on Safari mobile from accessing iPad's Orientation sensors. (22/2/2024)
  6. // @include https://remote.wemod.com/#/app
  7. // @include https://remote.wemod.com/*
  8. // @include http://remote.wemod.com/*
  9. // @include https://wemod.com/*
  10. // @include http://*.wemod.com/*
  11. // @include https://*.wemod.com/*
  12. // @include *
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. // Is an iPad?
  22. var isiPad = /iPad/i.test(navigator.userAgent);
  23.  
  24. // Check if safari supports 'DeviceOrientationEvent'
  25. var supportsOrientation = 'DeviceOrientationEvent' in window;
  26.  
  27. // block access to orientation events
  28. if (isiPad && supportsOrientation) {
  29. window.addEventListener('deviceorientation', function(event) {
  30. // prevent the default handling of the event
  31. event.stopPropagation();
  32. event.preventDefault();
  33. // Log if the event is blocked
  34. console.log('Blocked device orientation event:', event);
  35. }, true);
  36. }
  37. })();