Script Hapoel Sans Bugs

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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()