LorientOwnage

Il écrit des trucs chelou Staline56 :malade:

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 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();
    })();

})();