Howrse smiley:3

old smileys

  1. // ==UserScript==
  2. // @name Howrse smiley:3
  3. // @namespace http://your.homepage/
  4. // @version 0.7
  5. // @description old smileys
  6. // @author Xavier
  7. // @include http://gaia.equideow.com/*
  8. // @include http://ouranos.equideow.com/*
  9. // @include http://wwww.howrse.de/*
  10. // @include http://wwww.howrse.com/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. function main(){
  15. var inter = setInterval(modifying,5000);
  16. }
  17.  
  18. function modifying(){
  19. var x = 0;
  20. var textarea;
  21. console.log("Starting");
  22. textarea = document.getElementsByTagName("textarea");
  23. for (x=0;x<textarea.length;x++){
  24. textarea[x].relatedtextarea=textarea[x];
  25. textarea[x].onkeyup=myFunc(textarea[x])
  26. }
  27. return 1;
  28. }
  29.  
  30. function myFunc(input){
  31. return function(){
  32. var possibleSmiley, match, i, myregex, text, place, smiley, cursor, curend, oldtext;
  33. i = 0;
  34. console.log("Changing to smiley");
  35. cursor = input.selectionStart;
  36. curend = input.selectionStart;
  37. possibleSmiley = ["(xd)","(o_O)","(bis)","(grr)","(zzz)","(D8)","(omg)","(ninja)","(8D)","(snif)","(lol)","(8P)","(euh)","(up)","(bad)","(8)","(ker)","(bg)","(8)","(h)","(blink)","(ski)","(mur)","(mmm)","(smoke)","(yeah)"];
  38. smileyregex = /\(\w{1,5}\)/g;
  39. imageregex = /((?:https?:\/\/|www\.)((\w|\/|\.|\:)+?\.(jpg|png|gif|bmp))\/?)/i;
  40. urlregex = /(?:https?:\/{2}|www\.)[\S]+?\.(?:\w{0,3}|[0-9])(?=([^\s\]\.]*))\1(?:\.php|\.html|\.asp|(?!\.))(?=([^\s\]]*))\2(?!([\]\[]))/i;
  41. smiley = "";
  42. text = input.value;
  43. match = text.match(smileyregex);
  44. if (match != null){
  45. console.log(match);
  46. for (i=0;i<match.length;i++){
  47. if(possibleSmiley.indexOf(match[i]) != -1){
  48. smiley = match[i].substr(1,match[i].length-2);
  49. cursor -= (smiley.length+2);
  50. smiley = "[img]http://smileys.alwaysdata.net/smileys/" + smiley + ".gif[/img]";
  51. cursor += smiley.length;
  52. place = smileyregex.exec(text);
  53. text = text.substr(0,place.index) + smiley + text.substr(place.index+1 + match[i].length-1, text.length-1);
  54. curend = cursor;
  55. }
  56. }
  57. }
  58.  
  59. match = urlregex.exec(text);
  60. while(match != null){
  61. console.log(match);
  62. url = match[0].substr(0,match[0].length);
  63. cursor += 6;
  64. text = text.substr(0,match.index) + "[url=" + url + "][/url]" + text.substr(match.index+match[i].length, text.length-1);
  65. matchi = imageregex.exec(url);
  66. if(matchi != null){
  67. console.log(matchi);
  68. img = matchi[0].substr(0,matchi[0].length);
  69. text = text.substr(0,match.index) + "[img]" + img + "[/img]" + text.substr(match.index+url.length+12, text.length-1);
  70. cursor += 5;
  71. }
  72. curend = cursor;
  73. match = urlregex.exec(text);
  74. }
  75.  
  76. input.value = text;
  77. input.selectionStart = cursor;
  78. input.selectionEnd = curend;
  79. }
  80. }
  81.  
  82. main();