Greasy Fork

Greasy Fork is available in English.

LorientOwnage

Il écrit des trucs chelou Staline56 :malade:

当前为 2016-07-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 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();
    })();

})();