Blocki

Block Instagram from registering that you've viewed stories

  1. // ==UserScript==
  2. // @name Blocki
  3. // @namespace https://github.com/jOaawd/
  4. // @version 1.0
  5. // @description Block Instagram from registering that you've viewed stories
  6. // @author https://github.com/jOaawd/
  7. // @match *://www.instagram.com/*
  8. // @grant none
  9. // @license CC BY-NC 4.0 https://creativecommons.org/licenses/by-nc/4.0/
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const blockPattern = /PolarisAPIReelSeenMutation|PolarisStoriesV3SeenMutation/i;
  16.  
  17. // XMLHttpRequest
  18. const originalXHROpen = XMLHttpRequest.prototype.open;
  19. const originalXHRSend = XMLHttpRequest.prototype.send;
  20.  
  21. XMLHttpRequest.prototype.send = function (body) {
  22. if (typeof body === 'string' && blockPattern.test(body)) {
  23. console.log('[Blocki] Blocked XHR story seen mutation:', body);
  24. return; // Block the request
  25. }
  26. return originalXHRSend.apply(this, arguments);
  27. };
  28.  
  29. // Fetch
  30. const originalFetch = window.fetch;
  31. window.fetch = function () {
  32. const args = arguments;
  33. let bodyToCheck = '';
  34.  
  35. try {
  36. const request = args[0];
  37. const options = args[1] || {};
  38. bodyToCheck = options.body || '';
  39.  
  40. if (typeof bodyToCheck === 'string' && blockPattern.test(bodyToCheck)) {
  41. console.log('[Blocki] Blocked fetch story seen mutation:', bodyToCheck);
  42. return new Promise(() => {}); // Return a never resolving Promise to silently cancel
  43. }
  44. } catch (err) {
  45. console.warn('[Blocki] Error checking fetch body', err);
  46. }
  47.  
  48. return originalFetch.apply(this, args);
  49. };
  50.  
  51. })();