Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PromoFaux
Last active December 26, 2021 00:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PromoFaux/87e3c2e224e4fb6ead25628753818aa3 to your computer and use it in GitHub Desktop.
Save PromoFaux/87e3c2e224e4fb6ead25628753818aa3 to your computer and use it in GitHub Desktop.
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