beehaw.org Ctrl + Enter to submit comment

beehaw.org Ctrl + Enter to submit comment 2

02.06.2023 itibariyledir. En son verisyonu görün.

// ==UserScript==
// @name        beehaw.org Ctrl + Enter to submit comment 
// @namespace   english
// @description beehaw.org Ctrl + Enter to submit comment  2
// @include     http*://*beehaw.org*
// @version     1.3
// @run-at document-end
// @license MIT
// @grant       GM_addStyle
// ==/UserScript==


// Main - CSS hides two classes - video add box, and call to action box under it. - also social media

document.body.addEventListener('keydown', (event) => {
    if(event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
        event.target.form?.submit();
    }
});


var keyboardEvent = document.createEvent('KeyboardEvent');
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';

keyboardEvent[initMethod](
  'keydown', // event type: keydown, keyup, keypress
  true, // bubbles
  true, // cancelable
  window, // view: should be window
  false, // ctrlKey
  false, // altKey
  false, // shiftKey
  false, // metaKey
  9, // keyCode: unsigned long - the virtual key code, else 0
  0, // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);




 keyboardEvent = document.createEvent('KeyboardEvent');
 initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';

keyboardEvent2[initMethod](
  'keydown', // event type: keydown, keyup, keypress
  true, // bubbles
  true, // cancelable
  window, // view: should be window
  false, // ctrlKey
  false, // altKey
  false, // shiftKey
  false, // metaKey
  13, // keyCode: unsigned long - the virtual key code, else 0
  0, // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);

 
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '    ';
document.getElementsByTagName('head')[0].appendChild(style);