Advertisement
omareco14

Facebook Chat Bracket Emoticons.user

Oct 3rd, 2014
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Facebook Chat Bracket Emoticons
  3. // @description    Replaces [[xxx]] expressions with their respective pictures on facebook chat. "The New Edition"
  4. // @author         Omar Abou Elmagd (http://www.facebook.com/omareco14)
  5. // @version        1.0
  6. // @include        https://*.facebook.*/*
  7. // @include        http://*.facebook.*/*
  8. // @include        https://www.facebook.com/*
  9. // @run-at         document-end
  10. // @grant          metadata
  11. // ==/UserScript==
  12. /*
  13. KeyboardShortcuts : خاصية تقوم بتحويل اختصار للكلام الي كلام معين
  14. مثال : فاكس تتحول الي [[faksse]]
  15. لتفعيل هذه الخاصيه
  16. قم بتغير الكلمه في السطر التالي من
  17. True الي False
  18. */
  19. var KeyboardShortcuts = false;
  20. /*
  21. TurningTo : خاصية تقوم بتحويل الايموشن من
  22. :] الي :D
  23. لتفعيل هذه الخاصيه
  24. قم بتغير الكلمه في السطر التالي من
  25. True الي False
  26. */
  27. var TurningTo = false;
  28.  
  29. var allElements = ["_5yl5", "UFICommentBody", "_5pbx userContent", "_38 direction_rtl"];
  30. var OldMemes = ["fakss", "atmz7", "8abyy", "wes5a"];
  31. var NewMemes = ["faksse", "atmz77", "8abbyy", "weth5a"];
  32. var OldWords = [":]", "فاكس", "هيرب ديرب"];
  33. var NewWords = [":D", "[[faksse]]", "[[8abbyy]]"];
  34. function KeyboardShortcutsFunction(){
  35.       if(KeyboardShortcuts==false){return;}
  36.       var Emot = document.getElementsByClassName("uiTextareaAutogrow _552m");
  37.       for(var i = 0; i<Emot.length;i++){
  38.            for (var iix = 0; iix < OldWords.length; iix++) {
  39.                if(Emot[i].value.indexOf(OldWords[iix]) != -1) {
  40.                     Emot[i].value = Emot[i].value.replace(OldWords[iix],NewWords[iix]);
  41.                }
  42.            }
  43.       }  
  44. }
  45. function TurningToFunction(){
  46.       if(TurningTo==false){return;}
  47.       var Emotion = document.getElementsByClassName("emoticon emoticon_smile");
  48.       for(var i = 0; i<Emotion.length;i++){
  49.            if(Emotion[i].getAttribute("title")==":]"){
  50.                 Emotion[i].setAttribute("class","emoticon emoticon_grin");
  51.                 Emotion[i].setAttribute("title",":D");
  52.            }
  53.       }
  54. }
  55. setInterval(function(){
  56.       for (var ii = 0; ii < allElements.length; ii++) {
  57.            var all = document.getElementsByClassName(allElements[ii]);
  58.            for(var i = 0; i<all.length;i++){
  59.                 if(all[i].innerHTML.indexOf("[[") != -1){
  60.                      var meme = all[i].innerHTML.substring(all[i].innerHTML.indexOf("[[")+2,all[i].innerHTML.indexOf("]]"));
  61.                      var newmeme = meme;for(var l=0;l<OldMemes.length;l++){if(meme==OldMemes[l]){newmeme=NewMemes[l];}}
  62.                      all[i].innerHTML = all[i].innerHTML.replace("[["+meme+"]]", '<img title="'+newmeme+'" alt="'+newmeme+'" height=16 width=16 src="https://graph.facebook.com/'+newmeme+'/picture?width=10&height=10">');
  63.                 }
  64.            }
  65.       }
  66.       KeyboardShortcutsFunction();
  67.       TurningToFunction();
  68. },10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement