Advertisement
Guest User

4chan quotescript using yen and greater than

a guest
Mar 18th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Press "." and do Quoting things on 4chanX
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Allows you to quote text without creating a quote link item in your post
  6. // @author ECHibiki - Sage
  7. // @match *://boards.4chan.org/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. var THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER = "`";
  13. var THAT_SECOND_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER = "~";
  14.  
  15.  
  16.  
  17. var qr_open = false;
  18.  
  19. document.addEventListener("keydown", function(e){
  20. if(e.key == THAT_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER && !(document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA")){
  21. var text = getSelectionText().split("\n");
  22. var intermed = text;
  23. text = (text.map(function(line){return line.trim() != "" ? "¥" + line : line;})).join("\n");
  24. e.preventDefault();
  25. e.stopPropagation();
  26. if(!qr_open) document.getElementsByClassName("qr-link")[0].click();
  27. setTimeout(function(){
  28. document.getElementById("qr").getElementsByTagName("TEXTAREA")[0].value += text + "\n";
  29. },100);
  30. return false;
  31. }
  32. if(e.key == THAT_SECOND_FIELD_YOU_CHANGE_TO_SET_YOUR_HOTKEY_CHARACTER && !(document.activeElement.tagName == "INPUT" || document.activeElement.tagName == "TEXTAREA")){
  33. var text = getSelectionText().split("\n");
  34. var intermed = text;
  35. text = (text.map(function(line){return line.trim() != "" ? ">" + line : line;})).join("\n");
  36. e.preventDefault();
  37. e.stopPropagation();
  38. if(!qr_open) document.getElementsByClassName("qr-link")[0].click();
  39. setTimeout(function(){
  40. document.getElementById("qr").getElementsByTagName("TEXTAREA")[0].value += text + "\n";
  41. },100);
  42. return false;
  43. }
  44. });
  45.  
  46.  
  47.  
  48. function getSelectionText() {
  49. var text = "";
  50. if (window.getSelection) {
  51. text = window.getSelection().toString();
  52. } else if (document.selection && document.selection.type != "Control") {
  53. text = document.selection.createRange().text;
  54. }
  55. return text;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement