Advertisement
Guest User

Untitled

a guest
Apr 11th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AveNoel Livraison
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://avenoel.org/topic/101099-1-aide-voici-un-script-pour-vous-faciliter-la-vie-sur-avn
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // https://pastebin.com/
  15. if (true) {
  16. testPost();
  17. return;
  18. }
  19. var detail = getDetailPatch();
  20. getInfoText(detail);
  21. getUpText(detail);
  22. })();
  23.  
  24. function getDetailPatch() {
  25. var patch = "3.13.0";
  26. var pastebin = "https://pastebin.com/raw/tid89WKZ";
  27. var details = [
  28. "+ gestion des sujets bannis"
  29. ];
  30.  
  31. // 3.13.0 : Pastebin => https://pastebin.com/raw/tid89WKZ
  32. // + gestion des sujets bannis
  33.  
  34.  
  35. var patchText =
  36. "<b>"+patch+
  37. "</b> : Pastebin => "+pastebin;
  38.  
  39. details.forEach(function (each) {
  40. patchText += "\n" + each;
  41. });
  42.  
  43. return patchText;
  44. }
  45.  
  46. function getInfoText(detail) {
  47. httpGetApiAsync("messages/1611709", function(res) {
  48.  
  49. var match = res.content.split("<b>Patch note :</b>");
  50. getArchiveText(match[1]);
  51. console.log(match[1]);
  52.  
  53. var newContent = match[0] + "<b>Patch note :</b>\n" +detail;
  54. // console.log(newContent);
  55.  
  56. });
  57.  
  58. }
  59.  
  60. function getArchiveText(previousPatch) {
  61. httpGetApiAsync("messages/1611720", function(res) {
  62. var newContent = res.content.replace(new RegExp("<b>Archives :</b>", "gm"), "<b>Archives :</b>" + previousPatch.slice(0, -3));
  63. // alert(newContent);
  64. });
  65. }
  66.  
  67. function getUpText(detail) {
  68.  
  69. var template =
  70. ":up:\n\n"+
  71. "<b>Patch note :</b>\n"+
  72. detail +
  73. "\nRécap des fonctionnalités => https://avenoel.org/topic/101099-1-aide-voici-un-script-pour-vous-faciliter-la-vie-sur-avn"+
  74. "\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";
  75.  
  76. console.log(template);
  77.  
  78. }
  79.  
  80. function testPost() {
  81. httpPostApiAsync("auth", {username : "MrPointVultTest", password : "MrPointVultTest"}, function (res) {
  82. httpPostApiAsync("messages", {topic_id : "101099", content : "ceci est un test", api_token:res.api_token}, function (res) {});
  83. });
  84. }
  85.  
  86.  
  87. function httpGetApiAsync(path, callback) {
  88. var xmlHttp = new XMLHttpRequest();
  89. xmlHttp.onreadystatechange = function() {
  90. if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
  91. callback(JSON.parse(xmlHttp.responseText).data);
  92. };
  93. xmlHttp.open("GET", "https://avenoel.org/api/v1/" + path, true); // true for asynchronous
  94. xmlHttp.send(null);
  95. }
  96.  
  97. function httpPostApiAsync(path, data, callback) {
  98. httpPostPutApiAsync("POST", path, data, callback);
  99. }
  100.  
  101. function httpPutApiAsync(path, dat, callbacka) {
  102. httpPostPutApiAsync("PUT", path, data, callback);
  103. }
  104.  
  105. function httpPostPutApiAsync(type, path, data, callback) {
  106. var json = JSON.stringify(data);
  107.  
  108. var xhr = new XMLHttpRequest();
  109. xhr.open(type, "https://avenoel.org/api/v1/" + path, true);
  110. xhr.setRequestHeader('Content-type','application/json; charset=utf-8');
  111. xhr.onload = function () {
  112. var users = JSON.parse(xhr.responseText);
  113. if (xhr.readyState == 4 && xhr.status == "200") {
  114. callback(JSON.parse(xhr.responseText));
  115. console.table(users);
  116. } else {
  117. console.error(users);
  118. }
  119. };
  120. xhr.send(json);
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement