Script Hapoel Sans Bugs

J'ai essayé de faire un script sans bugs...

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Script Hapoel Sans Bugs
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  J'ai essayé de faire un script sans bugs...
// @author       3lXouif_Hapoel (Positron)
// @match        https://www.jeuxvideo.com/*
// @match        http://www.jeuxvideo.com/*
// @grant        none
// ==/UserScript==

function replace() {
var y = document.getElementsByTagName("P");
var i;
for (i = 0; i < y.length; i++) {
  var reg=new RegExp(":hapoel:", "g");
  y[i].innerHTML = y[i].innerHTML.replace(reg,"<img border='0'src='http://image.noelshack.com/fichiers/2018/36/5/1536354479-hapoel.gif' alt=':hapoel:' />");
  reg=new RegExp(":hapoelia:", "g");
  y[i].innerHTML = y[i].innerHTML.replace(reg,"<img border='0'src='https://wiki.jvflux.com/images/8/85/Hapoelia.gif' alt=':hapoelia:' />");
  reg=new RegExp(":hapoel2:", "g");
  y[i].innerHTML = y[i].innerHTML.replace(reg,"<img border='0'src='https://cdn.discordapp.com/emojis/718481781501853707.png' width=16 height=16 alt=':hapoel2:' />");
}
}
var userInput = document.getElementById('message_topic');
userInput.onkeyup = function() {
  if(document.getElementById('message_topic').indexOf(":hapoel:") !== -1 || document.getElementById('message_topic').indexOf(":hapoelia:") !== -1 || document.getElementById('message_topic').indexOf(":hapoel2:") !== -1){
  replace()
  }
};

replace()