Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name AveNoel Livraison
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://avenoel.org/topic/101099-1-aide-voici-un-script-pour-vous-faciliter-la-vie-sur-avn
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // https://pastebin.com/
- if (true) {
- testPost();
- return;
- }
- var detail = getDetailPatch();
- getInfoText(detail);
- getUpText(detail);
- })();
- function getDetailPatch() {
- var patch = "3.13.0";
- var pastebin = "https://pastebin.com/raw/tid89WKZ";
- var details = [
- "+ gestion des sujets bannis"
- ];
- // 3.13.0 : Pastebin => https://pastebin.com/raw/tid89WKZ
- // + gestion des sujets bannis
- var patchText =
- "<b>"+patch+
- "</b> : Pastebin => "+pastebin;
- details.forEach(function (each) {
- patchText += "\n" + each;
- });
- return patchText;
- }
- function getInfoText(detail) {
- httpGetApiAsync("messages/1611709", function(res) {
- var match = res.content.split("<b>Patch note :</b>");
- getArchiveText(match[1]);
- console.log(match[1]);
- var newContent = match[0] + "<b>Patch note :</b>\n" +detail;
- // console.log(newContent);
- });
- }
- function getArchiveText(previousPatch) {
- httpGetApiAsync("messages/1611720", function(res) {
- var newContent = res.content.replace(new RegExp("<b>Archives :</b>", "gm"), "<b>Archives :</b>" + previousPatch.slice(0, -3));
- // alert(newContent);
- });
- }
- function getUpText(detail) {
- var template =
- ":up:\n\n"+
- "<b>Patch note :</b>\n"+
- detail +
- "\nRécap des fonctionnalités => https://avenoel.org/topic/101099-1-aide-voici-un-script-pour-vous-faciliter-la-vie-sur-avn"+
- "\n\nLes admins en sueur à la vue de mon script https://image.noelshack.com/fichiers/2016/31/1470336267-picsart-08-02-08-31-44.jpg";
- console.log(template);
- }
- function testPost() {
- httpPostApiAsync("auth", {username : "MrPointVultTest", password : "MrPointVultTest"}, function (res) {
- httpPostApiAsync("messages", {topic_id : "101099", content : "ceci est un test", api_token:res.api_token}, function (res) {});
- });
- }
- function httpGetApiAsync(path, callback) {
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
- callback(JSON.parse(xmlHttp.responseText).data);
- };
- xmlHttp.open("GET", "https://avenoel.org/api/v1/" + path, true); // true for asynchronous
- xmlHttp.send(null);
- }
- function httpPostApiAsync(path, data, callback) {
- httpPostPutApiAsync("POST", path, data, callback);
- }
- function httpPutApiAsync(path, dat, callbacka) {
- httpPostPutApiAsync("PUT", path, data, callback);
- }
- function httpPostPutApiAsync(type, path, data, callback) {
- var json = JSON.stringify(data);
- var xhr = new XMLHttpRequest();
- xhr.open(type, "https://avenoel.org/api/v1/" + path, true);
- xhr.setRequestHeader('Content-type','application/json; charset=utf-8');
- xhr.onload = function () {
- var users = JSON.parse(xhr.responseText);
- if (xhr.readyState == 4 && xhr.status == "200") {
- callback(JSON.parse(xhr.responseText));
- console.table(users);
- } else {
- console.error(users);
- }
- };
- xhr.send(json);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement