Skip to content

Instantly share code, notes, and snippets.

@bjb568
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjb568/8fbd436512884e3b6606 to your computer and use it in GitHub Desktop.
Save bjb568/8fbd436512884e3b6606 to your computer and use it in GitHub Desktop.
Downvotes, Closes as Unclear, Adds VLQ flag, and posts to chat
// ==UserScript==
// @name LQ button
// @author bjb568
// @version 2.0.2
// @namespace bjb568
// @description Adds a LQ button
// @include http://stackoverflow.com/questions/*
// @exclude http://stackoverflow.com/questions/tagged/*
// ==/UserScript==
var parent = document.getElementsByClassName('post-menu')[0];
if (!parent) return;
var lsep = document.createElement('span');
lsep.classList.add('lsep');
lsep.appendChild(document.createTextNode('|'));
parent.appendChild(lsep);
var a = document.createElement('a');
a.appendChild(document.createTextNode('LQ'));
parent.appendChild(a);
a.onclick = function() {
var n = location.href.match(/\/questions\/(\d+)/)[1];
GM_xmlhttpRequest({
method: 'POST',
url: 'http://stackoverflow.com/flags/questions/' + n + '/close/add',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: 'fkey=' + unsafeWindow.fkey.value + '&closeReasonId=Unclear'
});
GM_xmlhttpRequest({
method: 'POST',
url: 'http://stackoverflow.com/posts/' + n + '/vote/3',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: 'fkey=' + unsafeWindow.fkey.value
});
GM_xmlhttpRequest({
method: 'POST',
url: 'http://stackoverflow.com/flags/posts/' + n + '/add/PostLowQuality',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: 'fkey=' + unsafeWindow.fkey.value
});
GM_xmlhttpRequest({
method: 'GET',
url: 'http://chat.meta.stackexchange.com/rooms/89/tavern-on-the-meta',
onload: function(response) {
GM_xmlhttpRequest({
method: 'POST',
url: 'http://chat.meta.stackexchange.com/chats/766/messages/new',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: 'text=Unclear%20http%3A%2F%2Fstackoverflow.com%2Fq%2F' + location.href.match(/\/questions\/(\d+)/)[1] + '&fkey=' + response.responseText.match(/hidden" value="([\dabcdef]{32})/)[1]
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment