Tieba Quick Post

Press Ctrl + Enter to post a thread / comment on Tieba.

  1. // ==UserScript==
  2. // @name Tieba Quick Post
  3. // @version 1.0.1
  4. // @description Press Ctrl + Enter to post a thread / comment on Tieba.
  5. // @match http://tieba.baidu.com/*
  6. // @author 864907600cc
  7. // @namespace https://greasyfork.org/users/141
  8. // ==/UserScript==
  9.  
  10. var node,button;
  11. function add_event(){
  12. node=document.getElementById('ueditor_replace'),button=document.getElementsByClassName('poster_submit')[0];
  13. node.onfocus=function(){
  14. node.onkeydown=post_t;
  15. }
  16. node.onblur=function(){
  17. node.onkeydown=false;
  18. }
  19. }
  20. function post_t(event){
  21. if (event.ctrlKey==1&&event.keyCode==13) button.click();
  22. }
  23.  
  24. if(document.getElementById('ueditor_replace'))add_event();
  25. else {
  26. var editor_wait=window.setInterval(function(){
  27. if(document.getElementById('ueditor_replace')){
  28. window.clearInterval(editor_wait);
  29. add_event();
  30. }
  31. },100)
  32. }