Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Userscript to intercept the "publish release" button on Github to make sure the presser of said button is sure they want to press it
// ==UserScript==
// @name Github Release, are you sure??
// @version 0.1
// @description That green "Publish Release" button is just far too tempting to press when you want to save a draft.
// @author @promofaux
// @include *://github.com/*
// @icon https://www.google.com/s2/favicons?domain=github.com
// @grant none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==
(function($) {
'use strict';
function init() {
// from https://dzone.com/articles/intercepting-onclick-event
var btn = $("button.js-publish-release");
btn.data("funcToCall", btn.attr("onclick"));
btn.removeAttr("onclick");
btn.bind("click", function(e){
if (confirm("Are you sure?")){
var func = $(this).data("funcToCall");
eval(func);
}
else
{
return false;
}
});
}
document.addEventListener("pjax:end", init);
init();
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment