Git Product home page Git Product logo

advancedflagging's Introduction

Advanced Flagging

build

Advanced Flagging started as a set of modular TypeScript tools to aid with StackExchange Userscripts. It has support for:

  • SmokeDetector/metasmoke
  • Natty/Sentinel
  • Generic Bot
  • Guttenberg/CopyPastor
  • Chat

Credits

This code uses different bits and pieces from the following sources:

Installation

Direct install link | View source. Currently, only Tampermonkey is official supported.

What does it do?

Advanced Flagging adds icons from Smokey, Natty and Guttenberg to posts that have been reported. In addition, flags made through the Advanced Flagging interface are reported to Natty, Smokey, Guttenberg and Generic Bot if required.

Interface

Picture of the interface

Hovering over each option will show a tooltip describing the actions that will be performed on click:

tooltip showing actions

The script also monitors and reports the progress of each action the user decides to perform (e.g. flag, comment, send feedback):

progress I

progress II

progress III

progress IV

There's also support:

  • for flags manually raised through the flag dialog:

    screenshot of flag popup

    screenshot after flagging as spam

  • for the flags summary page:

    Screenshot from flags summary

  • for the "New Answers To Old Questions" page:

    image from NATO page

  • the Low Quality Answers review queue on Stack Overflow:

    screenshot from review

    after recommending deletion

Specialized reports

Guttenberg reports

When Guttenberg has detected a post, additional options appear in the dropdown:

Guttenberg report

Configuring Advanced Flagging

Advanced Flagging allows you to both edit any comments you choose to leave or flags you choose to raise and configure it so that the script is more convenient to use.

Configuration

The link to configure AdvancedFlagging is at the footer of each StackExchange site.

Picture of link to configuration

Clicking it opens the following modal box:

configuration modal

Comments and flags

The link to change the content of the comments and flags is in the footer of each StackExchange site as well:

Picture of the comments and flags link

It opens the following modal:

comments and flags modal

Click new button to add a new flag type and edit button to edit an existing one:

image

You can reset all flag types to default by clicking the reset button at the footer of the modal:

modal footer

Building

Install the dependencies with:

npm install

Then compile the code with:

npm run build

The distributable file is found under /dist/AdvancedFlagging.user.js and can be pasted directly into the userscript manager.

Bugs/Feature requests

For bugs or feature requests, please open an issue on GitHub.

advancedflagging's People

Contributors

bhargav-rao avatar danbopes avatar dependabot[bot] avatar double-beep avatar fastnlight0 avatar geisterfurz007 avatar kamil-tekiela avatar lucakiebel avatar machavity avatar papershine avatar raitalharehman avatar rjrudman avatar sri-shree avatar

Stargazers

 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

advancedflagging's Issues

Edge-Chromium (DEV) fails again?

@double-beep It seems that we have again a problem with advanced-flagging and Edge-Chromium (DEV). I am missing the link on the answers, while questions seems to be ok, but only if they don't have an answer. Edge DEV Version = 94.0.982.2 Tampermonkey version = 4.13.6138 AdvancedFlagging version = 1.3.7

Also the configuration links appears only on questions without answers and the block with the flags selection is missing.
missing-flags

Metasmoke doesn't open in Safari

Everytime I'm loading a page, the script tries to open metasmoke in a new tab, which doesn't work. Would it be possible to add an option in the footer that shows an Auth-URL when clicking it?

"Failed to send feedback to Natty" in Safari

When flagging a comment, the flag and comment are added, GenericBot succeeds, but it always ends with "Failed to send feedback to Natty"

The error appears to happen in this block (unminified from the minified version):

this.GetChannelPage(t).then(t => {
    const r = $("#active-user", $(t)).attr("class").match(/user-(\d+)/);
    r && r.length && e(parseInt(r[1], 10)),
    n("Could not find user id")
})

Based on the console output:

Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating '$("#active-user",$(t)).attr("class").match')

The same version of the script works for me in Chrome, Firefox, etc. I haven't heard of others failing in Safari (macOS 11.1, Safari 14 -- although it happened in 13.x as well), but perhaps I've missed something?

Running Tampermonkey 4.11.6117

Notice to indicate that user reached daily flag limit

I don't remember exactly but I think previous version of AF indicate that user reached daily flag limit but In new version it's gives wrong notification. Although user reached daily flag limit it's notify user as "Flagged" but actually there is not any flag raised. So it's better to give feedback to user like 'You reached daily flag limit, Flag is not raise ------'

Better comment detection

As an extension of #4 - we should be smarter about comments we auto-upvote. This may extend to have an entirely configurable flag system.

Bug: answerNode.attr(...) is undefined

While browsing in Stackoverflow I'm getting this error in the console:

answerNode.attr(...) is undefined

which comes from the function parseGenericePage

image

AdvancedFlagging: Changing the configuration for a flag type wipes out the Smokey feedback option

Steps to reproduce:

  1. Go to the bottom of a page and click the "AdvancedFlagging: edit comments and flags"
    image

  2. Click "Edit" to change the configuration for a flag. For example Spam.
    image
    image

  3. Save (does not matter if anything option is changed or not). At this point the problem has manifested. Go through the rest of the steps to see it

  4. Reload the page.

  5. Repeat 1. and 2.

Expected: The choice for "Feedback to Smokey" should remain to whatever was before saving.
Actual: The choice is wiped and set to "(none)".

image


This has been fixed as of 2023-01-23, however, that fix is not released yet. The latest release for AdvancedFlagging is from 2023-01-14.

The short summary of the technical issue is that for for Smokey the possible flag values are 'tpu-', 'tp-', 'fp-', 'naa-. However, when the ID for the radio button is generated via id: `advanced-flagging-${idedName}-feedback-${feedback}-${flagId}` that results in an ID with a double dash near the end.

<input class="s-radio" type="radio" id="advanced-flagging-Smokey-feedback-tpu--1" name="advanced-flagging-1-feedback-to-Smokey" data-feedback="">
<label class="s-label flex--item" for="advanced-flagging-Smokey-feedback-tpu--1">tpu-</label>

When data-feedback is to be populated, the value for it (in the latest release) comes from const [feedback] = radio.id.split('-').slice(-2, -1); which produces an empty string. Then saving takes that empty value for the Smokey configuration.

Add upvote to comment if already flagged

If I use Advanced Flagging to mark a Link Only answer that already has a Link Only comment, instead of doing nothing, it should upvote the current auto-comment with an upvote. (This should work the same for the others).

z-index issue with menu dropdown

Seems there might have been an update to SO, that caused the editor buttons to pop above the AdvancedFlagging tooltip:

A z-index of 3 on AdvancedFlaggings dl seems to correct the error.

Major Performance Concerns

As of late, I've had to disable AdvancedFlagging because of the delay added in my normal routine. At certain points, I've noticed 10+ second delays while my status bar reads "Waiting for tampermonkey". As soon as I disable AdvancedFlagging, this went away.

I have a sneaking suspicion, that there is some type of cache that when grows is causing these delays. When I uninstalled AdvancedFlagging and re-enabled it, the issues seemed to go away for roughly a few days. Sorry this ticket is a bit broad, if you don't have time to look into it, when I get more free time I can dig into this a bit more.

No more working in Edge DEV version 90.0.810.1?

It seems that this script stopped working after the release 90.0.810.1 of Edge DEV (Chromium) They have introduced a new system to hide extensions from the toolbar but after moving Tampermonkey out of sight this script stopped working and even putting Tampermonkey again in the toolbar hasn't solved the issue. There is no more a link "Advanced flagging" under answers and questions that allows me to do the flagging.

Get user name on FlagTypes.ts

Is there any way to get username( who post a answer ). I want to change some message and try to dig more on script. Actually Its not a bug but I don't know where I post this.
For example:

Welcome to StackOveflow [Want to get User name here]. However, this does not provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractions

Unchecking Downvote post for the Spam Flag Type causes all settings to be defaulted

If I uncheck "Downvote" under spam settings:
Screen Shot 2022-05-16 at 17 56 33

Click save and refresh the page. All AdvancedFlagging configurations get reset to the default.

This appears to be due to the following line:

if (!globals.cachedFlagTypes.length || !globals.cachedFlagTypes[0]?.Downvote) cacheFlags();

I'm not sure what the intention of !globals.cachedFlagTypes[0]?.Downvote is, however, since Downvote is present in the first FlagType (spam) it pulls the value, which in this case is false since the "Downvote post" checkbox is unchecked.

globals.cachedFlagTypes[0]:

{
    "Id": 1,
    "DisplayName": "Spam",
    "FlagText": "",
    "Comments": {
        "Low": "",
        "High": ""
    },
    "ReportType": "PostSpam",
    "Feedbacks": {
        "Smokey": "tpu-",
        "Natty": "tp",
        "Guttenberg": "",
        "Generic Bot": "track"
    },
    "BelongsTo": "Red flags",
    "IsDefault": true,
    "SendWhenFlagRaised": true,
    "Downvote": false,
    "Enabled": true
}

With the above configuration !globals.cachedFlagTypes[0]?.Downvote => !false => true which in turn runs cacheFlags() which entirely blanks out all configurations.

If we're testing for a specific structure an explicit comparison to undefined might be better globals.cachedFlagTypes[0]?.Downvote === undefined or even globals.cachedFlagTypes[0].hasOwnProperty('Downvote').

NAAhighrep is not upvoted

When the comment NAAlowrep already exists on a post and you select "Not an answer" from the list that comment gets upvoted.
This is not the case if the comment NAAhighrep already exists and "Not an answer" is selected from the dropdown menu.

A way to review comments before clicking them

I think there should be a way to view what a comment would be if posted.

For example, when hovering over a link like "Not an answer", it should display a tooltip which contains the comment that would be posted if that option was clicked.

Another thing I thought of was to have a sort of "confirmation" screen, so you click a link and it pops up a box basically asking if you are sure and displays the comment that will be posted - however I think the tooltip is a better idea because it doesn't require an extra click or anything, and it doesn't get in the way.

Guttenberg reports should only have one feedback option

Currently, users can select 'Plagiarism' or 'Duplicate answer'.

We should only display one of these if Guttenberg reports a post. It should be automatically detected, based on author ids, whether or not it's a duplicate answer, or plagiarism.

Red flag icon is not appear after flagged answer which indicate that answer is already flagged.

When ever I flagged from AF red flag appear which indicate that i already feed back (Flagged) that answer but now red flag is not appear ? I feel that this problem is appear when SO change comment flagged style and now dark red icon indicate comment flag which is already flagged .Class or some thing change so AF is not able catch that and unable to indicate that. (I am not sure but I guess ). Already flagged answer also show in 10 k tools with red flag but now it's also missing on 10 k tools.

Missing flagged icon after refreshing/revisiting a thread

When I have AdvanceFlagging enabled, the flag icon will be associated with that rather than the native SO "Flag" button. When you flag a post with AdvanceFlagging the red flag icon shows up; however, if you refresh the page or come back to it later, you don't see the red flag anymore and to know whether you acted on the post or not, you have to click on native "Flag" button and see if there's an existing flag from you on this post.

It would be great to fetch that data and show the red flag icon in case the user has flagged the post earlier.

Clarification:

Here's a screenshot of how it looks like when flagging:

image

If I refresh the same page, the red flag goes away:

image

If I want to know if I have already flagged this or not, I need to open Flag window of SO and it will tell me:

image

However, there's no way to tell if I had acted previously on a post by clicking on AdvanceFlagging.

AdvancedFlagging link not showing on firefox

From this comment

I have an issue with Advanced Flagging not showing up as link below posts. I installed it from https://github.com/SOBotics/AdvancedFlagging/raw/master/dist/AdvancedFlagging.user.js , refreshed an SO post website I had open, cancelled the MS dialog and opened another reported post. However the link still wasn't there. I restarted my browser (Firefox 58.0.1) but still nothing. I also uninstalled Natty Reporter which I had previously installed. Any idea why that might happen?

Flagging as NAA no longer sends feedback to Natty

Previously, flagging a post as NAA would have the same effect as using the "Advanced Flagging -> "Not an answer" with the "Send feedback to Natty" checked.

This is no longer occurring. When I flag as NAA, no feedback is sent. However, I can still manually use the "Advanced Flagging" menu to do so, but this is a lot of extra clicks.

ReferenceError: $ is not defined

ReferenceError: $ is not defined
webpack_modules moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:590
webpack_require moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1954
webpack_modules moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:472
webpack_require moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1954
webpack_modules moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:48
webpack_require moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1954
VM4yt3pnxrkm9 moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1965
VM4yt3pnxrkm9 moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1967
VM4yt3pnxrkm9 moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/ Advanced Flagging.user.js#3:1969
Ut moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected-web.js:1
ScriptData moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected-web.js:1
onHandle moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected-web.js:1
Lt moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected-web.js:1
post moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected.js:1
$t moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected.js:1
Lt moz-extension://580650f0-6c14-4307-81bd-eca3503d91bd/injected.js:1
Advanced Flagging.user.js:1969:28

I am getting the above error in console and the script seems to have stopped working.

Browser: Firefox 108.0.1, Ubuntu and Violentmonkey for userscript manager.

Send feedback when flagging/reviewing manually

NattyReporter detects, when you flag or review a post (only if you recommend deletion in the LQPRQ) and sends feedback to Natty (or report it, if Natty didn't find the post).

It would be nice to have the same functionality included in AdvancedFlagging

Investigate using tampermonkey storage

Currently, we use a combination of cross domain caching and localstorage.

However, tampermonkey exposes GM_getValue and GM_setValue. They also expose GM_listValues and GM_deleteValue.

GM_addValueChangeListener also looks super interesting.

According to this, values are cross domain as well.

Show the count of reamining flags for the day

I believe it's a useful feature to show the number of flags remaining in Advance Flagging like the count in native Flag window. Not sure if this helps but I provided the CSS path for the count.

CSS paths for an answer and a question:

html.html__responsive body.question-page.unified-theme div.container div#content.snippet-hidden div div.inner-content.clearfix div#mainbar div#answers div#answer-60746839.answer.deleted-answer div.post-layout div.answercell.post-layout--right div.grid.mb0.fw-wrap.ai-start.jc-end.gs8.gsy div.grid--cell.mr16 div.post-menu div#popup-flag-post.popup form div.popup-actions div span.flag-remaining-inform span.bounty-indicator-tab.supernovabg
html.html__responsive body.question-page.unified-theme div.container div#content.snippet-hidden div div.inner-content.clearfix div#mainbar div#question.question div.post-layout div.postcell.post-layout--right div.mb0 div.mt16.grid.gs8.gsy.fw-wrap.jc-end.ai-start.pt4 div.grid--cell.mr16 div.post-menu div#popup-flag-post.popup form div.popup-actions div span.flag-remaining-inform span.bounty-indicator-tab.supernovabg

Using this you may also be able to address this other issue https://github.com/SOBotics/AdvancedFlagging/issues/36at the same time by checking if the count is zero and then returning a warning pop-up, etc.

Not working with Microsoft Edge

Hello, I am using Microsoft Edge with TamperMonkey installed as a userscript manager.

However, as tested, it is not working on Microsoft Edge, but working on Chrome. Why this?

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.