3 ms·
> Any suggestions? Paste this into the console on https://news.ycombinator.com/submit https://news.ycombinator.com/submit and try submitting a Show HN. Some co
by bramgg 12y ago
> Any suggestions?
Paste this into the console on https://news.ycombinator.com/submit https://news.ycombinator.com/submit and try submitting a Show HN. Some code is odd in order to make it browser-pasteable. Obviously rules can be changed to what you think are most important.
var title=document.querySelector('[name="title"]'),submit=document.querySelector('[type="submit"]'),alreadyShow=!1;window.accept=function(){var e=document.querySelectorAll(".show-rule:checked").length;3!==e?(submit.disabled=!0,submit.style.opacity=.5):(submit.disabled=!1,submit.style.opacity=1)},title.addEventListener("input",function(e){if("show hn"!==e.target.value.substr(0,7).toLowerCase()){submit.disabled=!1,alreadyShow=!1;var t=document.querySelector(".show-guidelines");return void(t&&t.parentNode.removeChild(t))}if(!alreadyShow){alreadyShow=!0;var o=document.createElement("div");o.className="show-guidelines",o.style.height="80px",o.innerHTML=' <div style="position: absolute; margin: 15px 28px;"> Please ensure your post follows the <a href="https://news.ycombinator.com/showhn.html">Show HN Guidelines</a>. In short:<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> I made this new thing.<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> People can play with it.<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> I\'m happy to receive feedback. </div> ';var i=document.querySelector("form tbody tr:nth-of-type(7)");i.parentNode.insertBefore(o,i),accept()}},!1);
- bramgg 12y agoSlight revision, forgot to reset the submit button's opacity after canceling the Show HN prefix: var title=document.querySelector('[name="title"]'),submit=document.querySelector('[type="submit"]'),alreadyShow=!1;window.accept=function(){var e=document.querySelectorAll(".show-rule:checked").length;3!==e?(submit.disabled=!0,submit.style.opacity=.5):(submit.disabled=!1,submit.style.opacity=1)},title.addEventListener("input",function(e){if("show hn"!==e.target.value.substr(0,7).toLowerCase()){submit.disabled=!1,submit.style.opacity=1,alreadyShow=!1;var t=document.querySelector(".show-guidelines");return void(t&&t.parentNode.removeChild(t))}if(!alreadyShow){alreadyShow=!0;var o=document.createElement("div");o.className="show-guidelines",o.style.height="80px",o.innerHTML=' <div style="position: absolute; margin: 15px 28px;"> Please ensure your post follows the <a href="https://news.ycombinator.com/showhn.html">Show HN Guidelines</a>. In short:<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> I made this new thing.<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> People can play with it.<br> <input class="show-rule" type="checkbox" onclick="window.accept()"> I\'m happy to receive feedback. </div> ';var i=document.querySelector("form tbody tr:nth-of-type(7)");i.parentNode.insertBefore(o,i),accept()}},!1);