Bunpro: Disable Backspace Undo

Disables the backspace functionality in reviews

  1. // ==UserScript==
  2. // @name Bunpro: Disable Backspace Undo
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.6
  5. // @description Disables the backspace functionality in reviews
  6. // @author Kumirei
  7. // @include *bunpro.jp/*
  8. // @exclude *community.bunpro.jp*
  9. // @require https://greasyfork.org/scripts/370623-bunpro-helpful-events/code/Bunpro:%20Helpful%20Events.js?version=974369
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. var $ = window.$;
  15. $('html')[0].addEventListener('quiz-page', ()=>{
  16. var input_elem = $('#study-answer-input');
  17. $('body').keydown((event)=>{
  18. var colors = input_elem.css('background-color').match(/\d+/g);
  19. var sum = colors.reduce((a, b)=>Number(a)+Number(b));
  20. var redness = colors[0]/sum;
  21. if (event.keyCode == 8 && redness > 0.4) {
  22. event.stopPropagation();
  23. input_elem.blur();
  24. }
  25. });
  26. });
  27. })();