Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created January 24, 2012 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rlemon/1670907 to your computer and use it in GitHub Desktop.
Save rlemon/1670907 to your computer and use it in GitHub Desktop.
abandoned user script
// ==UserScript==
// @name LookAtMeINeedFlags
// @author rlemon, jamesgifford
// @version 0.2
// @namespace rlemon.com
// @description Flag SE Questions as Duplicates / Abandoned
// @include http://*stackoverflow.com/*
// @include http://*superuser.com/*
// @include http://*serverfault.com/*
// @include http://*askubuntu.com/*
// @include http://*stackapps.com/*
// @include http://*.stackexchange.com/*
// @include http://answers.onstartups.com/*
// ==/UserScript==
function EmbedCodeOnPage(kode) {
var elm = document.createElement('script');
elm.textContent = kode;
document.head.appendChild(elm);
}
function EmbedFunctionOnPageAndExecute(fn) {
EmbedCodeOnPage("(" + fn.toString() + ")()");
}
EmbedFunctionOnPageAndExecute(function () {
var clickHandler = function () {
$('.action-subform.mod-attention-subform textarea').val($(this).text());
$('.action-subform.mod-attention-subform input[name=prefilled]').trigger('click');
};
$(document).on('ajaxComplete', function () {
var new_option_links = [$('<a>', {
'text': 'I\'m a Duplicate!',
'click': clickHandler
}), $('<a>', {
'text': 'I\'m Abandoned!',
'click': clickHandler
})],
subform = $('.action-subform.mod-attention-subform ul');
$.each(new_option_links, function (i, val) {
var li = $('<li>');
li.append(val);
subform.append(li);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment