Advertisement
Guest User

GMCLAN Emoticon Fix v2

a guest
Nov 17th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        GMCLAN Emoticon Fix
  3. // @namespace   mailto:korodzik@poczta.onet.pl
  4. // @description Inserts emoticons properly into old GMCLAN forum posts. [After an update of the Invision forum software, old posts have lost their smileys, leaving just their names behind; this script inserts the smiley images again where needed.]. Rewritten by adam014 ;)
  5. // @include     *forum.gmclan.org*
  6. // @version     1.1 (2021.11.17)
  7. // @grant       none
  8. // ==/UserScript==
  9. //thanks to http://greasemonkey.win-start.de/patterns/match-attribute.html for help
  10.  
  11. const customEmoticons = {
  12.     '-_-': 'sleep.gif',
  13.     ':(': 'sad.gif',
  14.     ':)': 'smile.gif',
  15.     ':D': 'biggrin.gif',
  16.     ':P': 'tongue2.gif',
  17.     ':]': 'emot11.gif',
  18.     ':alien:': 'alien.gif',
  19.     ':angel_not:': 'angel_not.gif',
  20.     ':angry1:': 'angry1.gif',
  21.     ':angry:': 'angry.gif',
  22.     ':ban:': 'ban.gif',
  23.     ':bann:': 'bann.gif',
  24.     ':bash:': 'bash.gif',
  25.     ':beer:': 'beer.gif',
  26.     ':beta:': 'beta.gif',
  27.     ':blink:': 'blink.gif',
  28.     ':blush:': 'blush.gif',
  29.     ':book:': 'book.gif',
  30.     ':borek:': 'emot_borek.png',
  31.     ':boxed:': 'boxed.gif',
  32.     ':bye1:': 'bye1.gif',
  33.     ':cat:': 'cat.gif',
  34.     ':censored:': 'censored.gif',
  35.     ':cheers:': 'cheers.gif',
  36.     ':chris:': 'chris.gif',
  37.     ':closedeyes:': 'closedeyes.gif',
  38.     ':clover:': 'clover.gif',
  39.     ':cold2:': 'cold2.gif',
  40.     ':confused:': 'confused.gif',
  41.     ':construction:': 'construction.gif',
  42.     ':cool2:': 'cool2.gif',
  43.     ':crosseyed:': 'crosseyed.gif',
  44.     ':crying:': 'crying.gif',
  45.     ':death:': 'death.gif',
  46.     ':devil2:': 'devil2.gif',
  47.     ':devil:': 'devil.gif',
  48.     ':dots:': 'dots.gif',
  49.     ':excl:': 'excl.gif',
  50.     ':frusty:': 'frusty.gif',
  51.     ':glare:': 'glare.gif',
  52.     ':gnysek:': 'emot_gnysek.png',
  53.     ':greedy:': 'greedy.gif',
  54.     ':hammer:': 'hammer.gif',
  55.     ':helpsmilie:': 'helpsmilie.gif',
  56.     ':hitler:': 'hitler.gif',
  57.     ':hmmm:': 'hmmm.gif',
  58.     ':huh:': 'huh.gif',
  59.     ':innocent:': 'innocent.gif',
  60.     ':jason:': 'jason.gif',
  61.     ':kicking:': 'kicking.gif',
  62.     ':krider:': 'krider.gif',
  63.     ':laugh:': 'laugh.gif',
  64.     ':like:': 'like.png',
  65.     ':lol:': 'lol.gif',
  66.     ':lubieto:': 'lubieto.png',
  67.     ':mad:': 'mad.gif',
  68.     ':mellow:': 'mellow.gif',
  69.     ':ninja:': 'ninja.gif',
  70.     ':nuke:': 'nuke.gif',
  71.     ':o': 'ohmy.gif',
  72.     ':offtopic:': 'offtopic.gif',
  73.     ':online2long:': 'online2long.gif',
  74.     ':oops:': 'oops.gif',
  75.     ':paperbag3:': 'paperbag3.gif',
  76.     ':ph34r:': 'ph34r.gif',
  77.     ':play_ball:': 'play_ball.gif',
  78.     ':poster_oops:': 'poster_oops.gif',
  79.     ':prop:': 'prop.gif',
  80.     ':psichix:': 'emot_psichix.png',
  81.     ':ranmus:': 'emot_ranmus.png',
  82.     ':ranting2:': 'ranting2.gif',
  83.     ':red_bandana:': 'red_bandana.gif',
  84.     ':red_indian:': 'red_indian.gif',
  85.     ':rip:': 'rip.gif',
  86.     ':rockon:': 'rockon.gif',
  87.     ':rolleyes:': 'rolleyes.gif',
  88.     ':santa:': 'santa.gif',
  89.     ':shuriken:': 'shuriken.gif',
  90.     ':sick:': 'sick.gif',
  91.     ':sleep1:': 'sleep1.gif',
  92.     ':sleeping:': 'sleeping.gif',
  93.     ':smartass:': 'smartass.gif',
  94.     ':smile3:': 'smile3.gif',
  95.     ':sp_ike:': 'sp_ike.gif',
  96.     ':spam:': 'spam.gif',
  97.     ':stupid:': 'stupid.gif',
  98.     ':thumbsup:': 'thumbsup.gif',
  99.     ':tongue:': 'tongue.gif',
  100.     ':tv_happy:': 'tv_happy.gif',
  101.     ':tv_horror:': 'tv_horror.gif',
  102.     ':twisted:': 'twisted.gif',
  103.     ':unsure:': 'unsure.gif',
  104.     ':uzjel:': 'uzjel.png',
  105.     ':w00t2:': 'w00t2.gif',
  106.     ':w00t:': 'w00t.gif',
  107.     ':wacko:': 'wacko.gif',
  108.     ':weight_lift2:': 'weight_lift2.gif',
  109.     ':weight_lift:': 'weight_lift.gif',
  110.     ':wheelchair:': 'wheelchair.gif',
  111.     ':whip:': 'whip.gif',
  112.     ':whistling:': 'whistling.gif',
  113.     ':wink:': 'wink.gif',
  114.     ':wub:': 'wub.gif',
  115.     ';)': 'smile2.gif',
  116.     '<_<': 'dry.gif',
  117.     'B)': 'cool.gif',
  118.     '^_^': 'happy.gif'
  119. }
  120. var paragraphs = document.evaluate(
  121.   "//div[@data-role='commentContent']",
  122.     document,
  123.     null,
  124.     XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  125.     null);
  126.  
  127. for (var i = 0; i < paragraphs.snapshotLength; i++) {
  128.     var currentElement = paragraphs.snapshotItem(i);
  129.  
  130.     for (var text in customEmoticons) {
  131.         var emotFile = customEmoticons[text];
  132.         currentElement.innerHTML = currentElement.innerHTML.replaceAll(text,`<img src="https://forum.gmclan.org/uploads/emoticons/${emotFile}">`);
  133.     }
  134. }
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement