Giter Site home page Giter Site logo

ajgranowski / reddit-expanded-community-filter-userscript Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 1.11 MB

A userscript to filter muted communities from /r/all using your account preferences.

License: MIT License

JavaScript 8.74% TypeScript 53.99% Shell 4.52% PowerShell 0.16% Dockerfile 1.28% HTML 31.32%

reddit-expanded-community-filter-userscript's People

Contributors

ajgranowski avatar dependabot[bot] avatar step-security-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

reddit-expanded-community-filter-userscript's Issues

doesent work

even I have muted the community can still see in r/all
I also have tried to put // @match https://www.reddit.com/r/* in the code
maybe I need to configure Reddit in some way?

Add a build timestamp to the userscript

The userscript should include a timestamp of when it was built, similar to the timestamp embedded in the signature file.

Timestamp: Mon Jan 29 04:41:54 UTC 2024

Describe the solution you'd like
Add a timestamp comment for the time the script was built in the release userscript. This comment should be directly below the ==/UserScript== block. The timestamp should be in UTC, and should be human readable.

Examples:

// Build timestamp: Sat Feb 10 05:55:00 AM UTC 2024
// Build timestamp: 2024-02-10T05:55:00Z

Additional context
See the wiki for getting started.

These might also help:

Add support to sh.reddit.com (shreddit)

Is your feature request related to a problem? Please describe.
This script breaks for users drafted into testing the new Reddit layout. The new layout seems to be available at sh.reddit.com for testing.

Describe the solution you'd like
This script should work on both new.reddit.com and sh.reddit.com. This comment in #78 lays out some ideas for an approach, but some sort of strategy pattern seems appropriate.

Describe alternatives you've considered
We could redirect to new.reddit.com if we detect the shreddit layout, but it seems like Reddit wants shreddit to become the default experience eventually.

Additional context
This new layout uses "shreddit" prefixed elements.

Add internationalization

Is your feature request related to a problem? Please describe.
It would be cool to add i18n support to the script. Right now, all of the user interfaces only display in English.

Describe the solution you'd like
Add an i18n system to the script and internationalize the strings in DebugMenu.ts and TotalMutedPostsCounter.ts. We can use navigator.languages to determine the users language preference.

Internationalized strings should support templates.

Unable to retrieve ___r JSON from window. Access token failing back to scraping.

Describe the bug
With the recent Reddit update, access token retrieval also changed. Scraping from /coins still appears to work for now.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to https://www.reddit.com/r/all/ while logged in.
  2. Enable Debug Mode from the script control panel.
  3. Refresh the page.
  4. Observe that an Unable to retrieve ___r JSON from window. warning appears in the console.

Expected behavior
No warnings appear in the console on page load.

Desktop:

  • Firefox 120.0.1
  • Violentmonkey 2.16.0

Logs:

Error: Unable to retrieve ___r JSON from window.
    fromWindow moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:117
    fromWindow moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:356
    promisify moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:327
    promisify moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:326
    updateAccessToken moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:357
    start moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:445
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:572
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:579
    qt moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    <anonymous> moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:1
    Pe moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    post moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    ScriptData moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    onHandle moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    Le moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
Reddit expanded community filter.user.js:360:19

Failing back to scraping.

Redact sensitive information from logs

Is your feature request related to a problem? Please describe.
There is no log redaction, and part of the bug report process includes users posting their logs. It's possible for users to accidentally leak their access token if it's ever mistakenly printed to console and they report a bug.

Describe the solution you'd like
Logs should be intercepted, either by overwriting the window.console object or by using a different logger that supports redaction.

Describe alternatives you've considered

  • We could ask users to scan their logs before submitting them to remove any sensitive data, but that is likely too high of an ask for bug reports.
  • We could remove all logs, but that would make bug reports a lot harder to resolve.
  • We could hide the token in a procedure rather than returning a string, but it's still possible that the procedure could leak the token. This also doesn't support other kinds of redaction, such as their username.
  • We could develop a log preprocessor for bug reports, but that's not something that GitHub natively supports and would significant new infrastructure.

Additional context
See the wiki for getting started.

Add Fuzzing

Is your feature request related to a problem? Please describe.
OpenSSF recommends fuzzing, and adding fuzz testing to the project will increase the project's OpenSSF score.

Describe the solution you'd like
The recommended TypeScript tool for property-based fuzzing appears to be fast-check.

A solution should:

  1. Add a fuzzing tool.
  2. Identify critical areas in the code for fuzzing, such as user input or external data.
  3. Add fuzzing coverage to those identified areas.
  4. Open bug reports for any issues found by fuzzing.

Describe alternatives you've considered
fast-fuzz might work as an alternative. It doesn't seem like there's much consensus around fuzzing tools for TypeScript projects.

Additional context
See the wiki for getting started.

Reddit design update broke script

Describe the bug
I get an Error: Could not find main content element. error in debug mode, and posts from muted communities are no longer removed.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to https://www.reddit.com/r/all/ while logged in.
  2. Enable Debug Mode from the script control panel.
  3. Refresh the page.
  4. Observe that an Error: Could not find main content element. error appears in the console.

Expected behavior
No errors appear in the console on page load.

Desktop:

  • Firefox 120.0.1
  • Violentmonkey 2.16.0

Logs:

Error: Unable to retrieve ___r JSON from window.
    fromWindow moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:117
    fromWindow moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:356
    promisify moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:327
    promisify moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:326
    updateAccessToken moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:357
    start moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:445
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:572
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:579
    qt moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    <anonymous> moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:1
    Pe moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    post moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    ScriptData moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    onHandle moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    Le moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
Reddit expanded community filter.user.js:360:19

Failing back to scraping. Reddit expanded community filter.user.js:361:19

Muted subreddits: Array(31) [ … ] Reddit expanded community filter.user.js:481:17

Error: Could not find main content element.
    getFeedContainer moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:268
    startObserving moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:431
    promise callback*startObserving moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:430
    startPromise moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:455
    promise callback*start moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:454
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:572
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:579
    qt moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    <anonymous> moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:1
    Pe moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    post moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    ScriptData moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    onHandle moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    Le moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
Reddit expanded community filter.user.js:577:13
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:577
    (Async: promise callback)
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:576
    VM83artn0g9co moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:579
    qt moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    <anonymous> moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/ Reddit expanded community filter.user.js#24:1
    (Async: Async)
    Pe moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    post moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    ScriptData moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    onHandle moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1
    Le moz-extension://88feb08e-155c-4cf2-a137-d89373a2d63b/sandbox/injected-web.js:1

Additional context
This appears to be caused by a design update. The feed now appears to be a <shreddit-feed> element, and posts now appear to be <article>s. It looks like there is also an issue with retrieving the access token, but the fallback method appears to be working so far.

Posts are not muted after changing the feed sort

Describe the bug
Top posts that should be muted are not muted when changing the feed sort (Hot, New, Top, Rising).

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to https://www.reddit.com/r/all/top/ while logged in.
  2. Enable Debug Mode from the script control panel.
  3. Mute the subreddit of the top post.
  4. Refresh.
    • Observe that the top post is highlighted with a dashed red border.
  5. Navigate to https://www.reddit.com/r/all/new/.
  6. Refresh.
  7. Change the feed sort from New to Top from the feed header.
    • Observe that the top post is not highlighted, even though the subreddit is muted.

Expected behavior
Posts from muted subreddits should be removed after changing the feed sort.

Additional context
See the wiki for getting started.

I'm guessing the mutation observer isn't getting triggered. This would be a good place to start investigating.

All else fails, a hacky workaround could be calling refresh() if we detect the URL changing after a sort change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.