16

Questions on Stack Exchange are subject to auto-deletion rules which are a bit too complex for most people to remember easily. I'd like to know if a question I'm looking at is scheduled for deletion, because I may want to save it or avoid wasting my close/delete votes on it.

I am looking for a userscript or browser extension that:

  1. Adds a visual indication to Stack Exchange question page if the question is scheduled for deletion*.
  2. Indicates when (approximately) the deletion is scheduled to happen.
  3. Works in Chrome.

A search through Stack Apps did not turn up anything related.


* I understand that every new question is eligible for deletion in 365 days if nothing happens to it. If only 9-day and 30-day rules are checked, that's fine.

  • 7
    4. insults user in IE – bjb568 Mar 13 '15 at 2:59
5

I've made a userscript for this. I've tested it on a few questions shown by Franck's helpful query and it works, so it should work for the rest of the questions :)

To install, please first install Tampermonkey and then the script.

// ==UserScript==
// @name         Will question be deleted?
// @namespace    http://stackexchange.com/users/4337810/%E1%94%95%E1%96%BA%E1%98%8E%E1%95%8A
// @version      1.2
// @description  Adds a message on questions which *might* be deleted by the SE delete bot
// @author       ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/%E1%94%95%E1%96%BA%E1%98%8E%E1%95%8A)
// @match        *://*.stackexchange.com/*
// @match        *://*.stackoverflow.com/*
// @match        *://*.superuser.com/*
// @match        *://*.serverfault.com/*
// @match        *://*.askubuntu.com/*
// @match        *://*.stackapps.com/*
// @match        *://*.mathoverflow.net/*
// @grant        none
// ==/UserScript==
function addWarning(title) {
    if (! $('#riskOfDeletion').length ) {
        $('#qinfo').append("<tr><td><p class='label-key' id='riskOfDeletion'>Risk of <br />deletion?</p></td><td style='padding-left:10px'><p class='label-key' title='"+title+"'><b>Yes</b></p></td></tr>");    
    }
}

var askedDaysAgo = $('.question-stats td:eq(1) p').text().split(' ')[0],
    voteCount = $('.vote-count-post').text(),
    answerCount = $('#answers-header div h2').text().split(' ')[0],
    id = $(location).attr('href').split('/')[4],
    sitename = $(location).attr('hostname').split('.')[0],
    currentTime = (new Date).getTime(),
    elevenMonths = 28927183,
    nineDays = 777600,
    fifteenDays = 1296000,
    commentCount = $('.question .comment').length;

//More than 30 days old:
if( voteCount <= -1 ) { //if the vote count is <= -1
    if( answerCount.trim() == '' ) { //if there are no answers
        $.getJSON("https://api.stackexchange.com/2.2/questions/" + id + "?order=desc&sort=activity&site=" + sitename, function(json) {
            if( !json.items[0].locked_date ) { //if it isn't locked
                if ( currentTime - json.items[0].creation_date >= fifteenDays ) { //only care if it will happen in the next 15 days
                    addWarning('Within 15 days');
                }
            }
        });
    }
}

//More than 365 days old:
$.getJSON("https://api.stackexchange.com/2.2/questions/" + id + "?order=desc&sort=activity&site=" + sitename, function(json) {
    var creationDate = json.items[0].creation_date,
        score = json.items[0].score,
        answers = json.items[0].answer_count,
        views = json.items[0].view_count;

    if( currentTime - creationDate <= elevenMonths ) { //If it's been at least 11 months (we don't care about questions newer than that, yet...)
        if( answers == 0 ) { //if there aren't any answers
            if( !json.items[0].locked_date ) { //if it is not locked
                if( views <= (Math.floor(currentTime/8.64e7) * 1.5)) { //if view count <= the age of the question in days times 1.5
                    if( commentCount <= 1 ) { //if there are 1 or 0 comments
                        addWarning('Within a month');
                    }
                }
            }            
        }        
    }    
});

//More than 9 days since closure:
$.getJSON("https://api.stackexchange.com/2.2/questions/" + id + "?order=desc&sort=activity&site=" + sitename, function(json) {
    if( json.items[0].closed_date ) { //if the question is closed
        var closedDate = json.items[0].closed_date,
            closedReason = json.items[0].closed_reason,
            score = json.items[0].score,
            answers = json.items[0].answer_count;

        if( closedReason != 'duplicate' ) { //if it's not been closed as a duplicate
            if( score <= 0 ) { //if the score is less than or equal to 0
                if( !json.items[0].locked_date ) { //if it is not locked
                    if( answerCount == 0 ) { //if it has 0 answers
                        if (!json.items[0].accepted_answer_id) { //if it has no accepted answer
                            addWarning('Within 9 days');
                        }
                    }
                }
            }
        }
    }
});

If there is a risk of deletion, within the time specified below, this is what you should see:

enter image description here

Rolling over the above will show you when it might be deleted.

Here's how it works:

  1. If the question is more than 30 days old, and ...

    • has −1 or lower score
    • has no answers
    • is not locked

Only starts checking if it's score is less than or equal to -1


  1. If the question is more than 365 days old, and ...

    • has a score of 0, or a score of 1 in case of deleted owner
    • has no answers
    • is not locked
    • has view count <= the age of the question in days times 1.5
    • has 1 or 0 comments

Only starts checking if it's been at least 11 months since the question was asked


  1. If the question was closed more than 9 days ago, and ...

    • not closed as a duplicate
    • has a score of 0 or less
    • is not locked
    • has no answers with a score > 0
    • has no accepted answer
    • has no pending reopen votes
    • has not been edited in the past 9 days

Only starts checking if the question is already closed

  • @Woodface Are all the conditions not AND ? And the currentDate was a mistake - date, time - same thing ;p I'll update the script after the 9day clarification - I might need to remove that as well :) – ᔕᖺᘎᕊ Mar 29 '15 at 19:34
  • 1
    Seems to work fine with Firefox and Greasemonkey too. – galacticninja Mar 30 '15 at 7:09
  • @galacticninja great! I specifically said about chrome because the questions was about that – ᔕᖺᘎᕊ Mar 30 '15 at 11:09

Your Answer

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