As part of my daily routine, I flag deleted questions on Stack Exchange. Usually, I see something like this:

enter image description here

And to flag a deleted post that I can't see, I have to open Postman and fake the POST request for flagging. This takes a lot of time and is inconvenient.

I want a userscript/extension that:

  • Adds a flag button to deleted post 404 pages
  • Ideally brings up the standard flag dialog, but it absolutely must allow me to input custom text for a 'requires moderator attention' flag. I don't really care about other flag types, so the standard dialog isn't required
  • Ideally it wouldn't require me to authenticate with the API, instead using the standard POST requests available inside the page (with my fkey).

Is there a script that can do this?

  • 5
    Regarding your second bullet: the only flag option for deleted posts is "other".
    – hichris123
    Nov 27, 2014 at 23:47
  • 1
    Is that allowed? Is it the daily routine of all SE moderators? If so, why doesn't that functionality exist? How do you find a good reason for flagging if you can't see the content any more? Jan 30, 2015 at 22:14
  • @ThomasW. It's allowed by the system, and it can be useful in a couple cases, primarily when you want to flag a user for something and their only content is deleted. It's not a daily routine for everyone, it's just a hobby I have.
    – Undo
    Jan 30, 2015 at 22:27

1 Answer 1

// ==UserScript==
// @name         Flag Link for Deleted Messages
// @namespace    http://github.com/
// @version      0.1
// @description  Eh.
// @author       Madara Uchiha
// @include        /http:\/\/.+\.stackexchange.com/
// @include        /http:\/\/.+\.stackoverflow.com/
// @include        /http:\/\/stackoverflow.com/
// @include        /http:\/\/askubuntu.com/
// @include        /https:\/\/.+\.stackexchange.com/
// @include        /https:\/\/.+\.stackoverflow.com/
// @include        /https:\/\/stackoverflow.com/
// @include        /https:\/\/askubuntu.com/
// @grant        none
// ==/UserScript==

if ($('h1:contains(Page Not Found)').length > 0) {
    var postId = document.location.href.match(/questions\/(\d+)\//)[1];
    var $a = $('<a />', {
        text: 'Flag this question',
        css : {
            float: 'right'
    var $spinner = $('<img />', {
        src: 'http://i.imgur.com/YPmA6Jk.gif',
        css: {
            position: 'fixed',
            top     : 0,
            right   : 0
    $a.on('click', function () {
        var flagMessage = prompt('Enter flag message here.');
        $.post('/flags/posts/' + postId + '/add/PostOther', {
            fkey     : StackExchange.options.user.fkey,
            otherText: flagMessage
        }, hideSpinner);
    $('#mainbar-full .subheader').append($a);
    $('#mainbar-full .subheader').append($spinner);


    function showSpinner() {

    function hideSpinner() {

Above userscript adds a link to the right of the header of every 404 page that allows you to flag the question with a custom flag via a simple prompt() call.


  • I've noticed that the userscript doesn't work (anymore?) in case the removed question is removed due to spam flags, while it does for deleted-but-not-as-spam posts.
    – ProgramFOX
    Jul 7, 2015 at 15:51
  • Well, the test is for "Page Not Found" to be on the page (in an <h1> element). If that's different, then the userscript would indeed not work. Jul 7, 2015 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.