Skip to content

Instantly share code, notes, and snippets.

@PSingletary
Forked from mary-ext/bsky-annoyances.txt
Created February 14, 2025 06:22
Show Gist options
  • Select an option

  • Save PSingletary/eafb9b0eb4c2033148ffb7acbfc48740 to your computer and use it in GitHub Desktop.

Select an option

Save PSingletary/eafb9b0eb4c2033148ffb7acbfc48740 to your computer and use it in GitHub Desktop.

Revisions

  1. @mary-ext mary-ext revised this gist Feb 14, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ globalThis.fetch = function (req, init) {

    // remove feed interaction tracking
    case '/xrpc/app.bsky.feed.sendInteractions':
    return req.json().then((data) => {
    return req.clone().json().then((data) => {
    data.interactions = data.interactions.filter((evt) => {
    switch (evt.event) {
    // requestLess and requestMore is a user-explicit action
  2. @mary-ext mary-ext revised this gist Feb 14, 2025. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ globalThis.fetch = function (req, init) {
    return req.json().then((data) => {
    data.interactions = data.interactions.filter((evt) => {
    switch (evt.event) {
    // requestLess and requestMore is a user-explicit action.
    // requestLess and requestMore is a user-explicit action
    case 'app.bsky.feed.defs#requestLess':
    case 'app.bsky.feed.defs#requestMore':
    return true;
    @@ -26,6 +26,7 @@ globalThis.fetch = function (req, init) {
    return false;
    });

    // nothing to send, don't bother contacting
    if (data.interactions.length === 0) {
    return Response.json({});
    }
  3. @mary-ext mary-ext revised this gist Feb 14, 2025. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,11 @@ globalThis.fetch = function (req, init) {
    // remove trending topics
    case '/xrpc/app.bsky.unspecced.getTrendingTopics':
    return Response.json({ suggested: [], topics: [] });

    // remove follow suggestions
    case '/xrpc/app.bsky.actor.getSuggestions':
    return Response.json({ actors: [] });

    // remove feed interaction tracking
    case '/xrpc/app.bsky.feed.sendInteractions':
    return req.json().then((data) => {
    @@ -20,14 +22,14 @@ globalThis.fetch = function (req, init) {
    case 'app.bsky.feed.defs#requestMore':
    return true;
    }

    return false;
    });

    if (data.interactions.length === 0) {
    return Response.json({});
    }

    req = new Request(req, { body: JSON.stringify(data) });
    return _fetch.call(this, req);
    });
    @@ -50,4 +52,4 @@ XMLHttpRequest.prototype.open = function (method, url, isAsync, user, password)
    }

    return _open.call(this, method, url, isAsync, user, password);
    };
    };
  4. @mary-ext mary-ext revised this gist Feb 14, 2025. 1 changed file with 5 additions and 13 deletions.
    18 changes: 5 additions & 13 deletions user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -15,24 +15,16 @@ globalThis.fetch = function (req, init) {
    return req.json().then((data) => {
    data.interactions = data.interactions.filter((evt) => {
    switch (evt.event) {
    case 'app.bsky.feed.defs#clickthroughItem':
    case 'app.bsky.feed.defs#clickthroughAuthor':
    case 'app.bsky.feed.defs#clickthroughReposter':
    case 'app.bsky.feed.defs#clickthroughEmbed':
    case 'app.bsky.feed.defs#interactionSeen':
    case 'app.bsky.feed.defs#interactionLike':
    case 'app.bsky.feed.defs#interactionRepost':
    case 'app.bsky.feed.defs#interactionReply':
    case 'app.bsky.feed.defs#interactionQuote':
    case 'app.bsky.feed.defs#interactionShare':
    return false;
    // requestLess and requestMore is a user-explicit action.
    case 'app.bsky.feed.defs#requestLess':
    case 'app.bsky.feed.defs#requestMore':
    return true;
    }

    return true
    return false;
    });

    if (data.interactions.length === 0) {
    console.log('interaction blocked');
    return Response.json({});
    }

  5. @mary-ext mary-ext revised this gist Feb 14, 2025. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,11 @@ globalThis.fetch = function (req, init) {
    return true
    });

    if (data.interactions.length === 0) {
    console.log('interaction blocked');
    return Response.json({});
    }

    req = new Request(req, { body: JSON.stringify(data) });
    return _fetch.call(this, req);
    });
  6. @mary-ext mary-ext created this gist Feb 14, 2025.
    2 changes: 2 additions & 0 deletions bsky-annoyances.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    bsky.app##+js(user-bsky-annoyances.js)
    main.bsky.dev##+js(user-bsky-annoyances.js)
    56 changes: 56 additions & 0 deletions user-bsky-annoyances.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    const _fetch = globalThis.fetch;
    globalThis.fetch = function (req, init) {
    if (req instanceof Request) {
    const url = new URL(req.url);

    switch (url.pathname) {
    // remove trending topics
    case '/xrpc/app.bsky.unspecced.getTrendingTopics':
    return Response.json({ suggested: [], topics: [] });
    // remove follow suggestions
    case '/xrpc/app.bsky.actor.getSuggestions':
    return Response.json({ actors: [] });
    // remove feed interaction tracking
    case '/xrpc/app.bsky.feed.sendInteractions':
    return req.json().then((data) => {
    data.interactions = data.interactions.filter((evt) => {
    switch (evt.event) {
    case 'app.bsky.feed.defs#clickthroughItem':
    case 'app.bsky.feed.defs#clickthroughAuthor':
    case 'app.bsky.feed.defs#clickthroughReposter':
    case 'app.bsky.feed.defs#clickthroughEmbed':
    case 'app.bsky.feed.defs#interactionSeen':
    case 'app.bsky.feed.defs#interactionLike':
    case 'app.bsky.feed.defs#interactionRepost':
    case 'app.bsky.feed.defs#interactionReply':
    case 'app.bsky.feed.defs#interactionQuote':
    case 'app.bsky.feed.defs#interactionShare':
    return false;
    }

    return true
    });

    req = new Request(req, { body: JSON.stringify(data) });
    return _fetch.call(this, req);
    });
    }
    } else if (req === 'https://bsky.app/ipcc') {
    // remove regional moderation (germany, brazil)
    return Response.json({ countryCode: 'US' });
    }

    return _fetch.call(this, req, init);
    };

    const _open = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function (method, url, isAsync, user, password) {
    // remove video session tracking
    {
    // `video.bsky.app` is a middleware that adds session tracking,
    // the actual files lives on `video.cdn.bsky.app`
    url = url.replace('://video.bsky.app/watch/', '://video.cdn.bsky.app/hls/');
    }

    return _open.call(this, method, url, isAsync, user, password);
    };