LorientOwnage

Il écrit des trucs chelou Staline56 :malade:

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 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         LorientOwnage
// @namespace     LorientOwnage
// @version      1.2
// @description  Il écrit des trucs chelou Staline56 :malade:
// @author
// @include     http://www.jeuxvideo.com/*
// @include     https://www.jeuxvideo.com/*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function(){
  'use strict'
  function isForum() {
        return (document.URL.indexOf("/0-") != -1) ? true : false;
    }
    function isTopic() {
        return (document.URL.indexOf("/42-") != -1 || document.URL.indexOf("/1-") != -1) ? true : false;
    }

  function changeSujet(){
    var array = document.getElementsByClassName('text-modo');
    for(var i=0;i <array.length; i++){
      if(array[i].text.trim() == "Lorient56") getSujet(array[i].parentElement.getAttribute("data-id"));
    }
  }

  function getSujet(id){
    GM_xmlhttpRequest({
    method: "GET",
    url: "https://warm-earth-35063.herokuapp.com/randomSujet",
    onload: function(result) {
      document.querySelector('li[data-id="'+id+'"] .topic-subject .topic-title').innerHTML= JSON.parse(result.responseText).sujet;
    }
    });
  }


  function changeTopic(){
    var lorientMessage = new Array();
    var array = document.getElementsByClassName('text-modo');
    if (document.getElementsByClassName('bloc-pseudo-msg')[0].text.trim() == "Lorient56") {
      if (array.length == 1) {
        getTopic(array[0].parentElement.parentElement.parentElement.parentElement.getAttribute("data-id"));
      }
      else {
        getTopic(array[0].parentElement.parentElement.parentElement.parentElement.getAttribute("data-id"));
        for (var i = 1; i < array.length; i++) {
          if (array[i].text.trim()=="Lorient56") {
            getMessage(array[i].parentElement.parentElement.parentElement.parentElement.getAttribute("data-id"));
          }
        }
      }
    }
    else {
      for (var i = 0; i < array.length; i++) {
        if (array[i].text.trim()=="Lorient56") {
            getMessage(array[i].parentElement.parentElement.parentElement.parentElement.getAttribute("data-id"));
        }
      }
    }
  }

  function getTopic(id){

      GM_xmlhttpRequest({
          method: "GET",
          url: "https://warm-earth-35063.herokuapp.com/randomTopic",
          onload: function(response) {
            document.querySelector('div[data-id="'+id+'"] .txt-msg').innerHTML = JSON.parse(response.responseText).textedefdp;
            document.querySelector('#bloc-title-forum').innerHTML = JSON.parse(response.responseText).sujet;
          }
      });

  }

  function getMessage(id){
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://warm-earth-35063.herokuapp.com/randomMessage",
        onload: function(response) {
          document.querySelector('div[data-id="'+id+'"] .txt-msg').innerHTML = JSON.parse(response.responseText).textedefdp;
        }
    });
  }

  (function startScript() {
        isForum() && changeSujet();
        isTopic() && changeTopic();
    })();

})();