Last active
December 26, 2021 00:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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