Code Monkey home page Code Monkey logo

reddit-moderator-toolbox's Introduction

toolbox for reddit

DeepScan grade chrome web store version mozilla add-ons version Discord

A set of tools to be used by moderators on Reddit in order to make their jobs easier. Install toolbox from the Chrome Webstore or the Mozilla add-ons store, or read the user documentation.

Reporting issues and feature requests

If you think you've found a bug, or want to suggest a new feature, please make a post on /r/toolbox before creating an issue on the repo!

Building and Contributing

Our contributing guide has information about how to get Toolbox set up and running locally, an overview of the project structure, and information about our workflow. If you want to get involved in development, start there!

Third-party Application Support

All Toolbox subreddit settings and data are stored in subreddit wikis through versioned JSON. Third party applications can use this data to hook into toolbox features like usernotes. Documentation for third-party application developers looking to integrate with toolbox can be found on our Github wiki.

reddit-moderator-toolbox's People

Contributors

adhesivecheese avatar adzm avatar aeurielesn avatar agentlame avatar amici-ursi avatar arresteddevelopment avatar blank-cheque avatar clienthax avatar creesch avatar dakta avatar dependabot[bot] avatar dequeues avatar duckofduckness avatar empyrical avatar enderchief avatar eritbh avatar garethp avatar github-actions[bot] avatar githue avatar jewel-andraia avatar jordanmilne avatar k3n avatar literallywth avatar lowsociety avatar molenzwiebel avatar noeatnosleep avatar shiruken avatar theenigmablade avatar venefilyn avatar xeoth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reddit-moderator-toolbox's Issues

General CSS issues

From @Geo1088 on August 23, 2017 14:17

Biggest visible issue with the style now is the new site relies on box-sizing: border-box; a lot, and toolbox's elements all assume box-sizing: content-box; instead. In general things need to be updated to adapt to the new CSS.

Copied from original issue: eritbh/reddit-moderator-toolbox#5

Implement context menu in pure CSS (also other stuff)

Annoying me because it opens up on page load and takes a second to collapse. The show/hide behavior can be done just with CSS transitions, so I'll look into doing it that way.

Also, on a slightly related note, there should be no left border on that menu since it butts up against the left side of the screen. It and the modbar handle should also be the same size as the bottombar handle when collapsed, preferably.

Add ability to view user reports even after approved.

New API feature allows one to view dismissed reports. It is an attribute of posts and comments that have dismissed reports. Only really has use on old reddit, and would be a major improvement.

Example:

user_reports_dismissed":[
   [
      "!!!!!!!!",
      1
   ],
   [
      "n-notice me mod-senpai",
      1
   ],
   [
      "Super retarded.",
      1
   ],
   [
      "Open borders for /r/drama and Israel!",
      1
   ],
   [
      "why would you do this?",
      1
   ],
   [
      "go back private ugh",
      1
   ]
]

Convert $.ajax calls to use fetch

Related to #44

fetch is supported on all relevant browser versions and has a much nicer API than $.ajax does.

Because $.ajax passes three parameters to its callbacks, it's more difficult to have it play well with promises, which can only represent a single value (we get around this now by promising an object with the callback values as properties, but this isn't ideal). fetch, on the other hand, promises a single Response object.

Additionally, Response is (relatively) easily serializable to/from JSON - e.g. we can get the response from the background page, convert it to JSON, and then let TBUtils.sendRequest convert the JSON it received from the background page back into a Response object with its constructor. For example:

// background script
browser.runtime.onMessage.addListener(async request => {
    const response = await fetch('...');
    const headers = {};
    for (const [k, v] of response.headers) {
        headers[k] = v;
    }
    return [response.text(), {
        status: response.status,
        statusText: response.statusText,
        headers,
    }];
});
// content script
const response = await browser.runtime.sendMessage({...}).then(responseData => new Response(...responseData));
doSomethingWith(response.json());

Implement TBUtils.tempBaseDomain as a stopgap measure

From @creesch on November 13, 2017 21:7

Basically there a few instances where TBUtils.baseDomain is used that makes it so people navigate away from the redesign alpha. Those instances need to be replaced by TBUtils.tempBaseDomain eritbh/reddit-moderator-toolbox@0be5240 so this doesn't happen. Once the alpha is over we simply replace these temp instances and go on our way.

TODO:

  • queue notifications
  • queue counters in modbar

Future TODO:

  • Message notifications
  • Other modbar counters

Copied from original issue: eritbh/reddit-moderator-toolbox#8

Explore the possibility of integrating new modmail in the jsapi flow

Currently new modmail is the odd one out that basically does a bit of a hybrid thing between old reddit and new reddit. We probably want to integrate it more into the new reddit jsAPI event flow so relevant buttons are easier to implement in new modmail as well.

Prompted today with me wanting to use the toolbox profile feature in modmail and finding out that we don't have any way to trigger it there. Which is very silly of course.

Instances of hacky 'new.reddit' subdomain usage.

From @creesch on August 22, 2017 20:11

Initially we cannot escape some hacky stuff to get it to work on the new.reddit subdomain. Obviously this will need to be fixed at a later date. This issue attempts to keep track of those instances.


Copied from original issue: eritbh/reddit-moderator-toolbox#1

work out a way to activate only one toolbox instance on new modmail.

"Old" and new toolbox will be running side by side and this is fine when confronted for most of the website as the old one will only activate on the old tech stack and the new one only on the new one. With the exception of new modmail.

Ideally when both toolbox versions are installed the new one will handle new modmail, but this requires the old one to not activate. I am thinking of getting the new toolbox version to write a key to localstorage on activation which can be used by old toolbox as an indicator to simply not activate. An alternative would simply be a class on the body.

This obviously requires a change in the old toolbox codebase as well. It needs to hold of activating on new modmail for a little bit in order to make it so V4 has already written the needed info.

Vertical bar in removal reason duplicates following removal reasons into the container

When you have a vertical bar | at the end (or near the end) of a removal reason's text, it will cause the following removal reasons to appear inside the removal reason, like a nested removal reason.

  1. Have a removal reason's text end with |
  2. Create removal reasons below that specific removal reason
  3. Try remove with the first reason and you will have checkboxes for the following removal reasons

Either move notifier checking to background or make the domain check more fine grained.

Due to how toolbox storage works we at some point decided to only check for notifications when on the "main" subdomain which was www. This worked fine when we only had to deal with np and language subdomains but became a bit of an issue when mod was introduced. However usually when someone has mod open they also have regular reddit open so updates to the counters would trickle through anyway.

With two toolbox versions things start to become complicated. If someone has both installed but basically only uses legacy the counters in modmail will never get updated.

This line of code is currently the problem

So what I want to do in order (and time available) is:

  1. Quick fix: if toolbox is open in the mod domain check if other reddit tabs are open with the same toolbox version and if that isn't the case make toolbox check on that domain anyway.
  2. Move the code that checks for updates and such to the background page and make each tab a consumer.
    • It might be a good idea to split background scripts and also make a backgroundUtils.js.
  3. Not sure if we can separate this from point 2, move notification code to the background page as well.

further improve frontend api event handling.

From @creesch on August 23, 2017 16:59

Context: eritbh/reddit-moderator-toolbox#2 (comment)

One thing that this doesn't (yet) do is information handling, I talked about it a bit on irc yesterday where I floated the idea of creating a toolbox wrapper in the container where the data is also kept. I'd like your thoughts about that.

So tblistener would receive the below data

{
	"className": "s4tft2m-2 dQciYQ",
	"type": "postAuthor",
	"data": {
		"author": "creesch",
		"score": 49,
		"voteState": 1
	}
}

And then in the container create something like

<span class="tb-container-wrapper"  data-type="postAuthor" data-author="creesch" data-score="49" data-votestate="1"></span>

Before passing on the event so that modules have the wrapper to do their things in and already have the data stored for other future usage.

The pro side of this is that you don't need each module to handle this for their own use case and that it allows a sort of 'safe haven' for toolbox elements where interference by RES and other extensions is less likely.

A possible con is that we will not need to act on each container, handling like this does write to the DOM on every event we receive though possibly impacting performance negatively.

Copied from original issue: eritbh/reddit-moderator-toolbox#6

Removal reasons doesn't automatically pop up after removing a thread

I remove a thread, and that's it, the thread gets removed. It should pop the removal dialog up, but for now I have to go into the thread manually and add the removal reason through a comment using the "add a removal reason" button.

Hopefully I'm not missing a setting here that makes that happen.

Some users experience errors with certain api related actions.

usernotes in new modmail don't function properly.

  • Double usernote buttons in the sidebar sometimes.
  • The popup misses the correct user context and shows up empty.
  • It appears we no longer show usernotes next to people in the conversation (this might be due to something I changed semi intentionally but probably isn't something people will like)

Rewrite build process

What the title says, gulp modules are maintained poorly and it is overly complicated to do it through the gulp flow while we only do some fairly basic stuff anyway.

Seems to me that a simple npm script is easier to maintain.

Add purify method to ALL THE THINGS

Before we even attempt to submit to AMO.

We make use of DOMPurify which is accessed through TBui.purify and we basically need to purify most places were we generate html if we want to be safe. But certainly where we use "outside" data like from the api which is still almost all the things.

In order to do that we need to make sure that

  • Nowhere we rely on attribute activated events (onclick="") as those will be removed by purify.
  • Make sure we don't rely on other stuff being scrubbed out.

Change webext API calls to use browser instead of chrome

Firefox implements a promise-based version of Chrome's chrome.* extension API, referenced as browser.*: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API

It also provides a polyfill to support Chrome: https://github.com/mozilla/webextension-polyfill

Given we're converting lots of our code to promises, I think it would make sense to use a promise-based browser API since it doesn't seem like it's otherwise much different (shouldn't require much logic rewriting, just cleanup).

Feature Request: Keyboard navigation

Feature Request:

I'm in the process of adding keyboard support for common mod actions in RES on a per-comment/post basis in the modqueue, such as [remove], [approve], but also [context]. For the context option, I've bound the key-press to fire a click event on the context link, so if the user has toolbox's context popup enabled, a key-press opens the popup.

My issue is that there appears to be no way to close the context popup from the keyboard. Is it possible to add an event listener to close the popup on Esc keyDown? I don't mind making the changes, but I'd like to know how it should be handled. Should an Esc keyDown close ALL open popups (e.g. if a context and usernotes popup is up), the most recently created popup, or something else?

I'm thinking it makes the most sense to add a 'keyDown' listener to $('body') which then fires a 'click' event on every link matching $('.mod-toolbox .tb-popup .tb-popup-header .buttons a.close'). So pressing Esc would close out every TBui popup.

Reddit Thread:

https://www.reddit.com/r/toolbox/comments/6v20yg/feature_request_close_popup_with_esc_key/

Feature request: add a setting to automatically archive comment removal modmail messages

This was requested in /r/toolbox here and here.

The "Send removal reasons as subreddit" setting currently warns "Note: these will appear in modmail and potentially clutter it up.", which feature would help avoid.

A couple questions:

  • Is it possible to enforce this setting (and the send as sub setting) for all mods in a subreddit?
  • If a subreddit is still using the old mod mail, is it better to have this setting be a noop or to hit the /archive endpoint anyway? The endpoint returns 404 if the conversationId is invalid.
  • Does toolbox currently contain any util for determining if a subreddit is on the new mod mail? (Aside from checking for the mod.reddit.com hostname, which only works when the user is checking modmail)

I'm happy to open a PR for this feature.

Rewrite modmatrix

From @creesch on November 13, 2017 21:15

Currently modmatrix fetches the possible actions from the dropdown in the menu which also makes it possible to grab the icons from the current reddit css. This will likely not be possible in the future.

Ideally we get the admins to include something in the front-end api but if that is not possible we have to put the list of possible actions somewhere in the code where we can easily maintain it and make the code robust enough to handle actions it doesn't know.

Copied from original issue: eritbh/reddit-moderator-toolbox#9

Sanitize settings on first load after upgrade

Currently all settings that ever have been are still around if someone upgrades. Same goes for settings import as it simply imports all settings without checking if the setting does exist.

I think we likely can automatically do this as TB.module keeps track of each setting per module. That still leaves us with a bunch of settings that are not registered

TODO:

  • Figure out if TB.module can easily be used for this.
  • Figure out if any settings are being used that are not registered on a module level.
  • Build clean up code for after people have upgraded.

TODO2:

  • Figure out if we also want to do this on settings import.

Refine queue creatures implementation.

The current implementation works most of the time but not always, some people have reported the creature staying on page until they change queue etc.

queuetools brainstorming

07:54 <@creesch> Geo1088: Oh man I just had an idea of how we can port queuetools to the api 
07:54 <@creesch> well part of it anyway... 
07:54 <@creesch> Not even sure it is a good idea but that is why I am typing it out here
07:55 <@creesch> Basically whenever someone activates queuetools it will add a checkbox to every mod actionable thing currently in view and then when people check the checkbox it will write the thing id to an array. That way when people scroll we can know the checked state and later act on it. 
07:55 <@creesch> Now that I typed it out I can already spot a few issues with this :D 
08:00 <@creesch> 1) we don't have a list of stuff currently in view, though we could always add the checkbox and just make it show on activation. 
08:00 <@creesch> 2) Api limits now have to be taken in account 

Convert UI to use icon font

From @creesch on December 4, 2017 6:52

The current icons belong to old reddit and don't really fit in new reddit. Probably also a good time to consider using a font based icon set so we don't have to mess with base64 blobs.


  • Modbar icons
  • Icon links in modsubs popup
  • Buttons for manipulating lists/tables in the settings window (e.g. shortcuts list)
  • Various places in the subreddit config dialog
  • A whole ton of other stuff

Copied from original issue: eritbh/reddit-moderator-toolbox#12

Custom pages for syntax highlighter

It would be awesome if there was an option to list additional wiki paths that the syntax highlighter should work on. I'm planning to put some script/bot configuration in there, and being able to make certain pages be opened with the syntax highlighting editor would be super neat.

For bonus points, ability to select type (yaml, json, css, etc) for each path, and maybe having wildcard paths.

Modlog search function

I want to build this as a redesign module simply because of the effort involved and it allows us to use some of the things old toolbox does not have.

Some considerations:

  • Have it trigger jsAPI functions to include toolbox userhistory, usernotes and modbutton.
  • For comments show the body by default.
  • We might want to look into storing the modlog in IndexedDB when the search is running and us that as a future cache. This is however not without issues as we might have an incomplete version of the modlog in the local database.

Flying snoo broke

Not sure if we messed up with the css or if the method we used to place a block on the bottom of reddit no longer works. Anyway, the tb-footer-block needs to be fixed.

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.