Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
2,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.15 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AveNoel
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.5.0
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://avenoel.org/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //-----------------------------------------------------
  12. // TODO list
  13. //-----------------------------------------------------
  14. //Et si tu pouvais add une messagerie facebook like avec les mp qui s'affiche en bas, ça serait pas mal.
  15. //classer les MPs en catégorie
  16. //voir ce que je peux faire des vidéos (possible de synchoniser ?)
  17. //masquer la pdp
  18. //-----------------------------------------------------
  19.  
  20. //Profils
  21. var regexList;
  22. var bansRegex;
  23. var profilUsers;
  24. var favProfiles;
  25. var banProfiles;
  26. var currentProfile;
  27. var colorListProfil = [
  28. "White",
  29. "LightBlue",
  30. "LightCoral",
  31. "LightCyan",
  32. "LightGoldenRodYellow",
  33. "LightGrey",
  34. "LightGreen",
  35. "LightPink",
  36. "LightSalmon",
  37. "LightSeaGreen",
  38. "LightSkyBlue",
  39. "LightSlateGrey",
  40. "LightSteelBlue"
  41. ];
  42.  
  43. //Topic
  44. var favs;
  45. var bans;
  46.  
  47. // Global
  48. var id = 0;
  49. var profil = {name:"rien"};
  50. const space = "&nbsp";
  51. const url = "https://avenoel.org";
  52. const imgQuote = "<img src=\"/images/topic/quote.png\" alt=\"Icône citation\" width=\"20\">";
  53. const imgEdit = "<img src=\"/images/topic/edit.png\" alt=\"Icône éditer\" title=\"Éditer le message\" width=\"20\">";
  54. const imgDelete = "<img src=\"/images/topic/delete.png\" alt=\"Icône suppression\" width=\"20\">";
  55.  
  56. (function() {
  57. 'use strict';
  58.  
  59. var t0 = performance.now();
  60.  
  61. //debugger;
  62. //localStorage.removeItem("favs");
  63. //localStorage.removeItem("bans");
  64. //localStorage.removeItem("favProfiles");
  65. //localStorage.removeItem("banProfiles");
  66. //localStorage.removeItem("profilUsers");
  67.  
  68. initProfil();
  69. initFunctions();
  70. setInterval(initCache, 1500);
  71. initCache();
  72.  
  73. var path = window.location.pathname;
  74.  
  75. if (path.startsWith('/profil')) {
  76. traiterProfil();
  77. } else {
  78. ajouterBarFav();
  79. if (path.startsWith('/forum')) {
  80. traiterForum();
  81. } else if (path.startsWith('/topic')) {
  82. traiterTopic();
  83. } else if (path.startsWith('/messagerie')) {
  84. traiterMessagerie();
  85. } else {
  86. console.log('Cas ' + path + " non traité.");
  87. }
  88. }
  89.  
  90. enhanceTextArea();
  91. controlVersion();
  92.  
  93. var t1 = performance.now();
  94. console.log("Call to AveNoel took " + (t1 - t0) + " milliseconds.");
  95.  
  96. })();
  97.  
  98. function initProfil() {
  99. var split = document.getElementsByClassName('navbar-user-avatar')[0].parentElement.href.split("/");
  100. profil.name = split[split.length-1];
  101. }
  102.  
  103. function initFunctions() {
  104. if (!String.prototype.splice) {
  105. /**
  106. * {JSDoc}
  107. *
  108. * The splice() method changes the content of a string by removing a range of
  109. * characters and/or adding new characters.
  110. *
  111. * @this {String}
  112. * @param {number} start Index at which to start changing the string.
  113. * @param {number} delCount An integer indicating the number of old chars to remove.
  114. * @param {string} newSubStr The String that is spliced in.
  115. * @return {string} A new string with the spliced substring.
  116. */
  117. String.prototype.splice = function(start, delCount, newSubStr) {
  118. return this.slice(0, start) + newSubStr + this.slice(start + Math.abs(delCount));
  119. };
  120. }
  121. }
  122.  
  123. function initCache() {
  124. profilUsers = localStorage.profilUsers === undefined ? {} : JSON.parse(localStorage.profilUsers);
  125. regexList = localStorage.regexList === undefined ? [] : JSON.parse(localStorage.regexList);
  126. bansRegex = localStorage.bansRegex === undefined ? [] : JSON.parse(localStorage.bansRegex);
  127. favs = localStorage.favs === undefined ? {} : JSON.parse(localStorage.favs);
  128. bans = localStorage.bans === undefined ? [] : JSON.parse(localStorage.bans);
  129. favProfiles = localStorage.favProfiles === undefined ? [] : JSON.parse(localStorage.favProfiles);
  130. banProfiles = localStorage.banProfiles === undefined ? [] : JSON.parse(localStorage.banProfiles);
  131. }
  132.  
  133. function controlVersion() {
  134. httpGetApiAsync("messages/1611709", function(res) {
  135.  
  136. var match = res.content.match(/[0-9]+\.[0-9]+\.[0-9]+/g);
  137. if (match && version !== match[0]) {
  138.  
  139. var patchNotes = res.content.split(match)[1].match(/[^\r\n]+/g);
  140. var div = document.getElementById('alertversion');
  141. var innerHTML =
  142. "La version " + match[0] + " est disponible => " +
  143. "<a href=\"https://avenoel.org/topic/101099-1-aide-voici-un-script-pour-vous-faciliter-la-vie-sur-avn\">ici</a>.";
  144. for(var i = 1; i < patchNotes.length -1; ++i) {
  145. innerHTML += "<li>" + patchNotes[i] + "</li>";
  146. }
  147. innerHTML +=
  148. "<br>N'oubliez pas de laisser un commentaire." +
  149. "<br><img class=\"board-noelshack\" src=\"https://image.noelshack.com/fichiers/2017/02/1484089609-coeur.png\">";
  150.  
  151. div.innerHTML = innerHTML;
  152. div.style.color = "red";
  153. }
  154. });
  155.  
  156.  
  157. }
  158.  
  159. //-----------------------------------------------------
  160. // Editeur de texte
  161. //-----------------------------------------------------
  162.  
  163. function enhanceTextArea() {
  164.  
  165. var textArea = document.getElementsByTagName("textarea")[document.getElementsByTagName("textarea").length - 1];
  166. if (!textArea) {
  167. return;
  168. }
  169.  
  170. if (textArea.value.length > 0) {
  171. textArea.selectionStart = textArea.value.length;
  172. textArea.focus();
  173. }
  174.  
  175. var edit = function(tagIn, tagOut) {
  176.  
  177. var start = textArea.selectionStart;
  178. var end = textArea.selectionEnd;
  179. textArea.value = textArea.value.splice(textArea.selectionEnd, 0, tagOut).splice(textArea.selectionStart, 0, tagIn);
  180. textArea.selectionStart = start + tagIn.length;
  181. textArea.selectionEnd = end + tagIn.length;
  182. textArea.focus();
  183.  
  184. };
  185.  
  186. var textAreaButtons = document.getElementsByClassName("form-group bbcodes")[document.getElementsByClassName("form-group bbcodes").length - 1];
  187.  
  188. var list = [
  189. {name:"R", tagIn:"<color=red>", tagOut:"</color>", color:"red"},
  190. {name:"G", tagIn:"<color=green>", tagOut:"</color>", color:"green"},
  191. {name:"B", tagIn:"<color=blue>", tagOut:"</color>", color:"blue"}
  192. ];
  193. var div = document.createElement('div');
  194. list.forEach(function(each) {
  195.  
  196. div.innerHTML = "<button type=\"button\" class=\"btn\" tabindex=\"-1\" data-type=\"tag\"><span>" + each.name + "</span></button>";
  197. var btn = div.firstChild;
  198. textAreaButtons.appendChild(btn);
  199. btn.style.color = each.color;
  200. btn.onclick = function() {edit(each.tagIn, each.tagOut);};
  201.  
  202. });
  203.  
  204. div.remove();
  205.  
  206. textArea.onfocusout = function () {
  207. var value = textArea.value;
  208. regexList.forEach(function(each) {
  209. value = value.replace(new RegExp(each.reg, "gm"), each.res);
  210. });
  211.  
  212. // Mort aux cucks
  213. textArea.value = value
  214. .replace(new RegExp(" cuck", "gm"), " candaule")
  215. .replace(new RegExp(" Cuck", "gm"), " Candaule")
  216. .replace(new RegExp(" CUCK", "gm"), " CANDAULE");
  217. };
  218.  
  219. manageRisiBank();
  220. }
  221.  
  222. function manageRisiBank() {
  223. var risiList = document.getElementsByClassName("risi-rlist")[0];
  224.  
  225. console.log(risiList);
  226.  
  227. risiList.childNodes[1].parentNode.insertBefore(risiList.childNodes[1], risiList.childNodes[0]);
  228.  
  229. }
  230.  
  231. //-----------------------------------------------------
  232. // Fav/Courriers
  233. //-----------------------------------------------------
  234.  
  235. function ajouterBarFav() {
  236.  
  237. var barFav = document.getElementsByClassName("col-md-3 col-sm-12 col-xs-12 pull-right hidden-sm hidden-xs");
  238. if (barFav.length === 0) {
  239. return;
  240. }
  241.  
  242. var idCourrier = getId();
  243. var idFavoris = getId();
  244. barFav[0].replaceChild(barFav[0].children[0].cloneNode(true), barFav[0].children[0]);
  245.  
  246. var listDiv = barFav[0].children[1];
  247. listDiv.classList = [];
  248. listDiv.innerHTML =
  249. "<section>"+
  250. " <div id=\"alertversion\"></div>"+
  251. " <div id=\""+idCourrier+"\"></div>"+
  252. " <div id=\""+idFavoris+"\"></div>"+
  253. //"<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/xh_bqcyqp64\"> </iframe>"+
  254. "</section>";
  255.  
  256. var rect = listDiv.getBoundingClientRect(),
  257. scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  258. var top = rect.top + scrollTop;
  259. var event = function(e) {
  260. if (window.scrollY > top) {
  261. listDiv.style.position = "absolute";
  262. listDiv.style.top = window.scrollY + 'px';
  263. } else {
  264. listDiv.style.position = null;
  265. listDiv.style.top = top + 'px';
  266. }
  267. };
  268. window.addEventListener('scroll', event);
  269. event.apply();
  270.  
  271. var documentTitle = document.title;
  272. var setMails = function(){
  273. httpGetAsync("https://avenoel.org/messagerie", function (html) {
  274. var mails = html.getElementsByClassName("active");
  275.  
  276. if (mails.length > 2) {
  277. document.title = "(" + (mails.length-2) + ") " + documentTitle;
  278. var innerHTMLCourrier = "Courrier" + ((mails.length-2) > 1 ? "s" : "") + " (" + (mails.length-2) + ")";
  279.  
  280. for(var i = 1; i < mails.length -1; ++i) {
  281. innerHTMLCourrier += "<li>";
  282. innerHTMLCourrier += mails[i].getElementsByClassName("author")[0].innerHTML + " : ";
  283. innerHTMLCourrier += mails[i].getElementsByClassName("title")[0].innerHTML;
  284. innerHTMLCourrier += "</li>";
  285. }
  286.  
  287. document.getElementById(idCourrier).innerHTML = innerHTMLCourrier;
  288. } else {
  289. document.title = documentTitle;
  290. document.getElementById(idCourrier).innerHTML = "";
  291. }
  292. });
  293. };
  294. setInterval(setMails, 30000);
  295. setMails.apply();
  296.  
  297. var setFavs = function(){
  298. httpGetAsync("https://avenoel.org/favoris", function (html) {
  299. var list = html.getElementsByTagName("tBody")[0].children;
  300. var buttonBar = document.getElementById(idFavoris);
  301. var innerHTMLFav = "Favoris";
  302.  
  303. for(var i = 0; i < list.length; i++) {
  304.  
  305. var fav = list[i];
  306. var sNbDiff = "";
  307. var nbDiff = 0;
  308.  
  309. var href = fav.children[1].children[0].href;
  310. var nb = fav.children[3].innerHTML.trim();
  311.  
  312. if (fav.children[0].children[0].href === window.location.href) {
  313. favs[href] = nb;
  314. localStorage.setItem("favs", JSON.stringify(favs));
  315. }
  316.  
  317. if (favs[href]) {
  318. if( favs[href] !== nb) {
  319. nbDiff = (nb - favs[href]);
  320. sNbDiff = "(" + nbDiff + ") ";
  321. }
  322. } else {
  323. favs[href] = nb;
  324. localStorage.setItem("favs", JSON.stringify(favs));
  325. }
  326.  
  327. var hrefEnd = fav.children[0].children[0].href;
  328. fav.children[1].children[0].href = hrefEnd;
  329.  
  330. fav.removeChild(fav.children[2]);
  331. fav.removeChild(fav.children[2]);
  332. fav.removeChild(fav.children[2]);
  333. fav.removeChild(fav.children[0]);
  334. var idLi = getId();
  335. innerHTMLFav += "<li id=\"" + idLi + "\">" + sNbDiff + fav.innerHTML + "</li>";
  336.  
  337. if (nbDiff !== 0) {
  338. scanQuote(hrefEnd, nbDiff, idLi);
  339. }
  340. }
  341.  
  342. document.getElementById(idFavoris).innerHTML = innerHTMLFav;
  343.  
  344. });
  345. };
  346. setInterval(setFavs, 30000);
  347. setFavs.apply();
  348. }
  349.  
  350. function scanQuote(href, nb, idLi) {
  351. deepScan(href, nb, idLi);
  352. }
  353.  
  354. function deepScan(href, nb, idLi) {
  355. httpGetAsync(href, function (html) {
  356.  
  357. var commentaires = html.getElementsByClassName("topic-messages")[0].children;
  358. for (var i = commentaires.length - 1; i > -1 && nb !== 0; i--) {
  359. nb--;
  360. if (commentaires[i].children[1].children[1].innerHTML.indexOf("https://avenoel.org/profil/" + profil.name + "\"") !== -1) {
  361. document.getElementById(idLi).children[0].style.color = "red";
  362. nb = 0;
  363. break;
  364. }
  365. }
  366.  
  367. if (nb > 0) {
  368. deepScan(getPageFromUrl(href, false) , nb, idLi);
  369. }
  370.  
  371. });
  372. }
  373.  
  374. //-----------------------------------------------------
  375. // Topic
  376. //-----------------------------------------------------
  377.  
  378. function traiterTopic() {
  379.  
  380. overloadButtonDeleteTopic();
  381.  
  382. var maxPage = window.location.href;
  383. var lstTopic = document.getElementsByClassName("topic-messages");
  384.  
  385. var trsTopic = lstTopic[0].children;
  386.  
  387. var body = document.body,
  388. html = document.documentElement;
  389. var height = Math.max( body.scrollHeight, body.offsetHeight,
  390. html.clientHeight, html.scrollHeight, html.offsetHeight );
  391.  
  392. var textArea = document.getElementsByTagName("textarea")[document.getElementsByTagName("textarea").length - 1];
  393.  
  394.  
  395. var event = function(e) {
  396. if (
  397. textArea !== document.activeElement &&
  398. document.body.scrollHeight === window.scrollY + window.innerHeight
  399. ) {
  400. maxPage = getPageFromUrl(maxPage, true);
  401. httpGetAsync(maxPage, function (html) {
  402.  
  403. var nbPage = html.getElementsByTagName("title")[0].innerHTML.match(/Page [0-9]+ /g);
  404. if(nbPage[0] === "Page 1 ") {
  405. return;
  406. }
  407. var size = lstTopic[0].children.length;
  408. lstTopic[0].innerHTML += "<div>"+nbPage+"</div>" + html.getElementsByClassName("topic-messages")[0].innerHTML;
  409. enhanceListTopicMessage(lstTopic[0].children, size);
  410. });
  411. }
  412. };
  413. window.addEventListener('scroll', event);
  414.  
  415. enhanceListTopicMessage(trsTopic);
  416. traiterNavBarTopic();
  417. }
  418.  
  419. function enhanceListTopicMessage(trsTopic, start) {
  420. var iTopic = 0;
  421. if (start) {
  422. iTopic = start;
  423. }
  424. for(; iTopic < trsTopic.length; ++iTopic) {
  425. traiterTrTopic(trsTopic[iTopic]);
  426. collapseQuote(trsTopic[iTopic]);
  427. overloadButtons(trsTopic[iTopic]);
  428. }
  429. }
  430.  
  431. function findNewTop(isUp, listTop) {
  432. for(var i = 0; i < listTop.length - 1; ++i) {
  433. if (listTop[i] <= window.scrollY && window.scrollY <= listTop[i + 1]) {
  434. return isUp ? listTop[i] : listTop[i + 1];
  435. }
  436. }
  437. }
  438.  
  439. function traiterNavBarTopic() {
  440.  
  441. var relativePath = "";
  442. getPath().split("-").splice(2).forEach(function(split) {
  443. relativePath += split + "-";
  444. });
  445. relativePath = relativePath.slice(0, -1);
  446.  
  447. var buttons = addButtonToNavBar(["buttonBan"]);
  448. var buttonBan = buttons[0];
  449.  
  450. // Bouton des bans
  451. var isInBan = contentsString(bans, relativePath) != -1;
  452. if (isInBan) {
  453. buttonBan.innerHTML = "DEBAN";
  454. buttonBan.onclick = function() {
  455. deleteFromCache(bans, "bans");
  456. };
  457. } else {
  458. buttonBan.innerHTML = "BAN";
  459. buttonBan.onclick = function() {
  460. addInCache(bans, "bans");
  461. };
  462. }
  463.  
  464. }
  465.  
  466. function addInCache(cacheList, cacheName) {
  467. console.log("addInCache : " + cacheName);
  468. cacheList.push(getPath());
  469. localStorage.setItem(cacheName, JSON.stringify(cacheList));
  470. ajouterBarFav();
  471. traiterNavBarTopic();
  472. }
  473.  
  474. function deleteFromCache(cacheList, cacheName) {
  475. console.log("deleteFromCache : " + cacheName);
  476.  
  477. var relativePath = "";
  478. getPath().split("-").splice(2).forEach(function(split) {
  479. relativePath += split + "-";
  480. });
  481. relativePath = relativePath.slice(0, -1);
  482.  
  483. var i = contentsString(cacheList, relativePath);
  484. if (i !== -1) {
  485. cacheList.splice(i, 1);
  486. localStorage.setItem(cacheName, JSON.stringify(cacheList));
  487. }
  488.  
  489. ajouterBarFav();
  490. traiterNavBarTopic();
  491. }
  492.  
  493. function traiterTrTopic(tr) {
  494.  
  495. if (tr.children.length === 0) {
  496. return;
  497. }
  498.  
  499. var name = tr.getElementsByClassName("message-username")[0].children[0];
  500. if (profilUsers[name.innerHTML]) {
  501. if (profilUsers[name.innerHTML].color) {
  502. name.style.color = profilUsers[name.innerHTML].color;
  503. }
  504. if (profilUsers[name.innerHTML].name) {
  505. name.innerHTML = profilUsers[name.innerHTML].name;
  506. }
  507. if (profilUsers[name.innerHTML].pdp) {
  508. tr.getElementsByClassName("message-avatar")[0].children[0].src = profilUsers[name.innerHTML].pdp;
  509. }
  510. }
  511.  
  512. var message = null;
  513. var rank = -1;
  514.  
  515. // Suppression des FDP
  516. banProfiles.some(function(connard) {
  517.  
  518. var id = getId();
  519. message = null;
  520. if (hasProfilLink(tr, connard.name)) {
  521. message = "<div id=\"" + id + "\"><span>Réponse sur" + space + "</span><a href=\"https://avenoel.org/profil/" + connard.name + "\">" + connard.name + "</a></div>";
  522. }
  523. if (hasProfilAvatar(tr, connard.name)) {
  524. message = "<div id=\"" + id + "\"><span>Message de" + space + "</span><a href=\"https://avenoel.org/profil/" + connard.name + "\">" + connard.name + "</a></div>";
  525. }
  526.  
  527. if (message !== null) {
  528. rank = connard.rank;
  529. return true;
  530. }
  531.  
  532. return false;
  533. });
  534.  
  535. if (rank == 2) {
  536. tr.innerHTML = message;
  537. tr.focus();
  538. } else {
  539. addButtonHiddenTopicMessage(tr, rank == 1);
  540. }
  541.  
  542. return tr.offsetTop;//getBoundingClientRect().top + window.pageYOffset;
  543. }
  544.  
  545. function collapseQuote(tr) {
  546.  
  547. var content = tr.getElementsByClassName("message-content")[0];
  548. if (!content) {
  549. return;
  550. }
  551.  
  552. var lines = content.innerHTML.match(/[^\r\n]+/g);
  553.  
  554. var ids = [];
  555. var currentLine;
  556. var lastRank = -1;
  557. var currentRank = -1;
  558. for(var i = lines.length - 1; i > -1; --i) {
  559. currentRank = calculRank(lines[i]);
  560.  
  561. if (lastRank > 0 && currentRank > lastRank) {
  562. lines.splice(i + 1, 0, "</div>");
  563. } else if (currentRank > 0 && currentRank < lastRank) {
  564.  
  565. var idButton = getId();
  566. var idDiv = getId();
  567. var beforeButton = "";
  568. for(var iGt = 0; iGt < currentRank; ++iGt) {
  569. beforeButton += "&gt; ";
  570. }
  571.  
  572. var buttonAll = "";
  573. if (currentRank === 1) {
  574. var idButtonAll = "buttonAll" + getId();
  575. buttonAll = "<button id=\"" + idButtonAll + "\" ></button>";
  576. ids.push({idButton:idButtonAll, idDiv:idDiv});
  577. }
  578.  
  579. var maskInnerHTML = "<span class=\"message-content-quote\">" + beforeButton + "<i><button id=\"" + idButton + "\" ></button>" + buttonAll + "</i></span><div id=\"" + idDiv + "\" >";
  580. ids.push({idButton:idButton, idDiv:idDiv});
  581. lines.splice(i + 1, 0, maskInnerHTML);
  582. }
  583.  
  584. lastRank = currentRank;
  585. }
  586.  
  587. content.innerHTML = lines.join('');
  588. addCollapseEvent(tr, ids);
  589. }
  590.  
  591. function addCollapseEvent(tr, ids) {
  592. ids.forEach(function(id) {
  593. var button = document.getElementById(id.idButton);
  594. button.style.border = "none";
  595. button.innerHTML = ">";
  596. button.style.textAlign = "center";
  597. var div = document.getElementById(id.idDiv);
  598. div.style.display = "none";
  599.  
  600. if (id.idButton.startsWith("buttonAll")) {
  601. button.innerHTML = "=>";
  602. button.onclick = function() {
  603.  
  604. button.innerHTML = button.innerHTML === "&lt;=" ? "=&gt;" : "&lt;=";
  605. var innerHTML = button.innerHTML === "&lt;=" ? "&lt;" : "&gt;";
  606. var buttonList = div.getElementsByTagName("button");
  607. for (var i = 0; i < buttonList.length; i++) {
  608. buttonList[i].innerHTML = innerHTML;
  609. }
  610.  
  611. var divList = div.getElementsByTagName("div");
  612. var display = button.innerHTML === "&lt;=" ? "" : "none";
  613. div.style.display = display;
  614. for (var j = 0; j < divList.length; j++) {
  615. divList[j].style.display = display;
  616. }
  617.  
  618. button.previousSibling.innerHTML = button.innerHTML === "&lt;=" ? "&lt;" : "&gt;";
  619.  
  620. };
  621. } else {
  622. button.onclick = function() {
  623.  
  624. button.innerHTML = button.innerHTML === "&lt;" ? "&gt;" : "&lt;";
  625. div.style.display = div.style.display === "none" ? "" : "none";
  626.  
  627. if (button.nextSibling !== null) {
  628. button.nextSibling.innerHTML = button.innerHTML === "&lt;" ? "&lt;=" : "=&gt";
  629. }
  630. };
  631. }
  632. });
  633. }
  634.  
  635. function calculRank(line) {
  636. var rank = -1;
  637. var index;
  638. var matcher = "quote\">&gt; ";
  639.  
  640. while (index != -1) {
  641. rank++;
  642. index = line.indexOf(matcher);
  643. matcher += "&gt; ";
  644. }
  645.  
  646. return rank;
  647. }
  648.  
  649. function addButtonHiddenTopicMessage(tr, isHidden) {
  650.  
  651. var aside = tr.getElementsByClassName("message-aside hidden-xs")[0];
  652. if (!aside) {
  653. return;
  654. }
  655. var content = tr.getElementsByClassName("message-content")[0];
  656. var header = tr.getElementsByClassName("message-header")[0];
  657. var ulHeader = header.getElementsByClassName("message-actions")[0];
  658. var footer = tr.getElementsByClassName("message-footer")[0];
  659.  
  660. //aside.children[0].children[0].src = "http://4.bp.blogspot.com/-MdNpMeXfP3k/UYkDoyQ32VI/AAAAAAAAcNU/q3Dnc5zB4Ic/s1600/Blocage.jpg";
  661.  
  662. var idButton = getId();
  663.  
  664. content.isHidden = isHidden;
  665. var innerButton = content.isHidden ? "Afficher" : "Masquer";
  666. ulHeader.innerHTML = "<button id=\"" + idButton + "\" >" + innerButton + "</button>" + ulHeader.innerHTML;
  667.  
  668. var imageUp = "<li><img src=\"https://img-fi-n2.akamaized.net/icons/svg/53/53604.svg\"></li>";
  669. var imageDown = "<li><img src=\"https://img-fi-n2.akamaized.net/icons/svg/53/53598.svg\" alt=\"Icône citation\"></li>";
  670.  
  671. var button = document.getElementById(idButton);
  672.  
  673. button.style.backgroundColor = "Transparent";
  674. button.style.border = "none";
  675.  
  676. button.onclick = function() {
  677. content.isHidden = !content.isHidden;
  678. button.innerHTML = content.isHidden ? imageUp : imageDown;
  679. content.style.display = content.isHidden ? "none" : "";
  680. footer.style.display = content.isHidden ? "none" : "";
  681. aside.style.display = content.isHidden ? "none" : "";
  682. };
  683. content.isHidden = !content.isHidden;
  684. button.onclick.apply();
  685. }
  686.  
  687. function overloadButtons(tr) {
  688. var header = tr.getElementsByClassName("message-header")[0];
  689. if (!header) {
  690. return;
  691. }
  692.  
  693. var imgs = header.getElementsByTagName("img");
  694. var img;
  695. for(var i = 0; i < imgs.length; ++i) {
  696. if (imgs[i].src === "https://avenoel.org/images/topic/delete.png") {
  697. img = imgs[i];
  698. }
  699. }
  700.  
  701. if (!img) {
  702. return;
  703. }
  704.  
  705. var button = img.parentElement;
  706. var href = button.href;
  707. button.href = "#";
  708. button.onclick = function() {
  709. if (window.confirm("Voulez vous supprimer le message ?")) {
  710. window.location.href = href;
  711. }
  712. };
  713.  
  714. }
  715.  
  716. function overloadButtonDeleteTopic() {
  717.  
  718. var buttons = document.getElementsByClassName("btn btn-danger");
  719. if (!buttons) {
  720. return;
  721. }
  722.  
  723. for(var i = 0; i < buttons.length; ++i) {
  724.  
  725. var button = buttons[i];
  726. button.href2 = button.href;
  727. button.href = "#";
  728. button.onclick = function() {
  729. if (window.confirm("Voulez vous " + this.innerHTML.toLowerCase() + " le topic ?")) {
  730. window.location.href = this.href2;
  731. }
  732. };
  733. }
  734.  
  735. }
  736.  
  737. //-----------------------------------------------------
  738. // Forum
  739. //-----------------------------------------------------
  740.  
  741.  
  742. function traiterForum() {
  743. var lst = document.getElementsByClassName("table table-striped topics");
  744. var trs = lst[0].children[1].children;
  745. for(var i = 0; i < trs.length; ++i) {
  746. traiterTrForum(trs[i]);
  747. }
  748. }
  749.  
  750. function traiterTrForum(tr) {
  751.  
  752. var name = tr.getElementsByClassName("topics-author")[0].children[0];
  753. if (profilUsers[name.innerHTML]) {
  754. if (profilUsers[name.innerHTML].color) {
  755. name.style.color = profilUsers[name.innerHTML].color;
  756. }
  757. if (profilUsers[name.innerHTML].name) {
  758. name.innerHTML = profilUsers[name.innerHTML].name;
  759. }
  760. }
  761.  
  762. //tr.getElementsByClassName("topic-icon")[0].children[0].children[0].src = "https://i.imgur.com/dTbiOHu.png";
  763.  
  764. // Suppression des caracteres ching chong
  765. // if (tr.innerText.match(/[\u3400-\u9FBF]/) || tr.innerText.match(/[\u0250-\u02AF)]/)) {
  766. // console.log("Suppression des caracteres ching chong");
  767. // tr.innerHTML = "";
  768. // return;
  769. // }
  770.  
  771. // Suppression des FDP
  772. if (banProfiles.some(function(connard) {
  773. if (hasProfilLink(tr, connard.name)) {
  774. console.log("Suppression du FDP : " + connard.name);
  775. tr.innerHTML = "";
  776. return true;
  777. }
  778. return false;
  779. })) {
  780. return;
  781. }
  782.  
  783. if (bans.some(function(url) {
  784. if (hasUrl(tr, url)) {
  785. console.log("Suppression du sujet : " + url);
  786. tr.innerHTML = "";
  787. return true;
  788. }
  789. return false;
  790. })) {
  791. return;
  792. }
  793.  
  794. if (bansRegex.some(function(regex) {
  795. if (tr.innerHTML.match(new RegExp(regex, "gm"))) {
  796. console.log("Suppression du sujet regex : " + regex);
  797. tr.innerHTML = "";
  798. return true;
  799. }
  800. return false;
  801. })) {
  802. return;
  803. }
  804.  
  805. // Surlignage
  806. if (favProfiles.some(function(surligne) {
  807. if (hasProfilLink(tr, surligne.name)) {
  808. console.log("Surlignage : " + surligne.name);
  809. tr.style.background = colorListProfil[surligne.color];
  810. return true;
  811. }
  812. return false;
  813. })) {
  814. return;
  815. }
  816.  
  817. }
  818.  
  819. //-----------------------------------------------------
  820. // Profil
  821. //-----------------------------------------------------
  822.  
  823. function traiterProfil() {
  824. var isMine = profil.name === document.getElementsByTagName("h2")[0].innerHTML;
  825. var elem = document.getElementsByClassName("profile-wrapper-right");
  826. currentProfile = window.location.href.substring("https://avenoel.org/profil/".length);
  827.  
  828. elem[0].innerHTML += "<div " + (isMine ? "hidden" : "") + ">Banni de rang <select id=\"idBanRank\"></select><div id=\"idBanRankDetail\"></div></div>";
  829. elem[0].innerHTML += "Topic couleur <select id=\"idFavColor\"></select><br/>";
  830. elem[0].innerHTML += "Profil couleur <select id=\"idProfilColor\"></select><br/>";
  831. elem[0].innerHTML += "Profil name <input class=\"profile-biography\" id=\"idProfilName\" type=\"text\" style=\"height: 30px;\" placeholder=\"" + currentProfile + "\"/>";
  832. elem[0].innerHTML += "Profil photo <input class=\"profile-biography\" id=\"idProfilPhoto\" type=\"text\" style=\"height: 30px;\" placeholder=\"Pas de photo\"/>";
  833.  
  834. // pdp --------------------------------------------------------------
  835. if (profilUsers[currentProfile] && profilUsers[currentProfile].pdp) {
  836. document.getElementsByClassName("profile-avatar")[0].children[0].src = profilUsers[currentProfile].pdp;
  837. }
  838. document.getElementById("idProfilPhoto").onkeypress = function(e) {
  839. if (e.charCode === 13) {
  840. updatePhotoProfil(document.getElementById("idProfilPhoto").value);
  841. }
  842. };
  843.  
  844. // name -------------------------------------------------------------
  845. if (profilUsers[currentProfile] && profilUsers[currentProfile].name) {
  846. document.getElementsByClassName("profile-title")[0].children[0].innerHTML = profilUsers[currentProfile].name;
  847. }
  848. document.getElementById("idProfilName").onkeypress = function(e) {
  849. if (e.charCode === 13) {
  850. renameProfil(document.getElementById("idProfilName").value);
  851. }
  852. };
  853.  
  854. // color list -------------------------------------------------------
  855. var colorList = [];
  856. for (var iColor = 0; iColor < colorListProfil.length; iColor++) {
  857. colorList.push(iColor);
  858. }
  859. // color ------------------------------------------------------------
  860. var hasColor = false;
  861. var colorProfil;
  862. if (profilUsers[currentProfile]) {
  863. colorProfil = profilUsers[currentProfile].color;
  864. colorizeProfil(colorProfil);
  865. }
  866.  
  867. createComboBox("idProfilColor", colorList);
  868. var comboProfilColor = document.getElementById("idProfilColor");
  869.  
  870. for (var k = 0; k < comboProfilColor.length; k++) {
  871. comboProfilColor[k].innerHTML = "";
  872. comboProfilColor[k].style.backgroundColor = colorListProfil[k];
  873. }
  874.  
  875. if (hasColor) {
  876. comboProfilColor.selectedIndex = parseInt(color);
  877. comboProfilColor.style.backgroundColor = colorListProfil[color];
  878. }
  879.  
  880. comboProfilColor.onchange = function(event) {
  881. colorizeProfil(colorListProfil[event.target.selectedOptions[0].value]);
  882. };
  883.  
  884.  
  885. // favoris ----------------------------------------------------------
  886. var isFav = false;
  887. var color = 0;
  888. favProfiles.some(function(fav) {
  889. if (fav.name === currentProfile) {
  890. isFav = true;
  891. color = fav.color;
  892. return true;
  893. }
  894. return false;
  895. });
  896.  
  897.  
  898.  
  899. createComboBox("idFavColor", colorList);
  900. var comboFavColor = document.getElementById("idFavColor");
  901.  
  902. for (var j = 0; j < comboFavColor.length; j++) {
  903. comboFavColor[j].innerHTML = "";
  904. comboFavColor[j].style.backgroundColor = colorListProfil[j];
  905. }
  906.  
  907. if (isFav) {
  908. comboFavColor.selectedIndex = parseInt(color);
  909. comboFavColor.style.backgroundColor = colorListProfil[color];
  910. }
  911.  
  912. comboFavColor.onchange = function(event) {
  913. favProfile(event.target.selectedOptions[0].value);
  914. };
  915.  
  916. // bans ----------------------------------------------------------
  917. detailRankProfile();
  918. var isBan = false;
  919. var rank = 0;
  920. banProfiles.forEach(function(connard) {
  921. if (connard.name === currentProfile) {
  922. isBan = true;
  923. rank = connard.rank;
  924. return;
  925. }
  926. });
  927.  
  928. createComboBox("idBanRank", ["non","0","1","2"]);
  929. var comboBanRank = document.getElementById("idBanRank");
  930. if (isBan) {
  931. comboBanRank.selectedIndex = parseInt(rank) + 1;
  932. }
  933. detailRankProfile(rank);
  934. comboBanRank.onchange = function(event) {
  935. banProfile(event.target.selectedOptions[0].value);
  936. };
  937.  
  938. if (isMine) {
  939. afficherConfig();
  940. }
  941.  
  942. }
  943.  
  944. function afficherConfig() {
  945. var container = document.getElementsByClassName("col-md-7 col-centered profile")[0];
  946. var editorContainer = container.appendChild(container.children[0].cloneNode(true));
  947. editorContainer.style.textAlign = "left";
  948. editorContainer.style.marginTop = "15px";
  949. editorContainer.innerHTML = "";
  950. var config = container.appendChild(container.children[0].cloneNode(true));
  951. config.style.textAlign = "left";
  952. config.style.marginTop = "15px";
  953.  
  954. var idEditor = getId();
  955. var idTopic = getId();
  956. var idBannis = getId();
  957.  
  958. config.innerHTML =
  959. "<div>Liste mots clés de l'éditeur de texte :</div>"+
  960. "<div id=\"" + idEditor + "\"></div>"+
  961. "<br>"+
  962. "<div>Liste mots clés du masques des sujets :</div>"+
  963. "<div id=\"" + idTopic + "\"></div>"+
  964. "<br>"+
  965. "<div>Liste des bannis :</div>"+
  966. "<div id=\"" + idBannis + "\"></div>";
  967.  
  968. addEditorToProfil(editorContainer);
  969. createConfigEditor(document.getElementById(idEditor));
  970. createConfigTopic(document.getElementById(idTopic));
  971. createConfigBannis(document.getElementById(idBannis));
  972. }
  973.  
  974. function addEditorToProfil(container) {
  975. if (true) {
  976. container.style.display = "none";
  977. }
  978. httpGetAsync("https://avenoel.org/forum", function (html) {
  979. var form = html.getElementsByTagName("form")[1];
  980.  
  981. //var risi = html.getElementsByClassName("btn risi-wlogo")[0];
  982. // risi.formAction = "https://avenoel.org/forum/#risibank";
  983. // console.log(risi.formAction);
  984.  
  985. container.appendChild(form.children[2]);
  986. container.appendChild(form.children[2]);
  987. container.appendChild(form.children[2]);
  988. enhanceTextArea();
  989. });
  990. }
  991.  
  992. function createConfigEditor(container) {
  993.  
  994. var lines = [];
  995. var innerHTML = "<li>";
  996. regexList.forEach(function (each) {
  997.  
  998. var res;
  999. if (each.res.startsWith("https://")) {
  1000. res = "<img class=\"board-noelshack\" src=\"" + each.res + "\">";
  1001. } else {
  1002. res = each.res;
  1003. }
  1004.  
  1005. var idButton = getId();
  1006. innerHTML +=
  1007. each.reg + " => " + res + space +
  1008. "<button id=\"" + idButton + "\">" + imgDelete + "</button>" +
  1009. "</li>" +
  1010. "<li>";
  1011. lines.push({id:idButton, each:each});
  1012. });
  1013.  
  1014. var idButtonPlus = getId();
  1015. var idInputKey = getId();
  1016. var idInputValue = getId();
  1017. innerHTML +=
  1018. "<input class=\"profile-biography\" id=\"" + idInputKey + "\" type=\"text\" style=\"height: 30px;\"/>" +
  1019. " => " +
  1020. "<input class=\"profile-biography\" id=\"" + idInputValue + "\" type=\"text\" style=\"height: 30px;\"/>" +
  1021. "<button id=\"" + idButtonPlus + "\">" + imgEdit + "</button>" +
  1022. "</li>";
  1023.  
  1024. container.innerHTML = innerHTML;
  1025.  
  1026. lines.forEach(function (line, i) {
  1027. var button = document.getElementById(line.id);
  1028. button.style.backgroundColor = "Transparent";
  1029. button.style.border = "none";
  1030.  
  1031. button.onclick = function() {
  1032. regexList.splice(i, 1);
  1033. localStorage.setItem("regexList", JSON.stringify(regexList));
  1034. createConfigEditor(container);
  1035. };
  1036. });
  1037.  
  1038.  
  1039. var buttonPlus = document.getElementById(idButtonPlus);
  1040. buttonPlus.style.backgroundColor = "Transparent";
  1041. buttonPlus.style.border = "none";
  1042.  
  1043. buttonPlus.onclick = function() {
  1044. regexList.push({reg:document.getElementById(idInputKey).value, res:document.getElementById(idInputValue).value});
  1045. localStorage.setItem("regexList", JSON.stringify(regexList));
  1046. createConfigEditor(container);
  1047. };
  1048. }
  1049.  
  1050. function createConfigTopic(container) {
  1051.  
  1052. var lines = [];
  1053. var innerHTML = "<li>";
  1054. bansRegex.forEach(function (each) {
  1055. var idButton = getId();
  1056. innerHTML +=
  1057. each + space +
  1058. "<button id=\"" + idButton + "\">" + imgDelete + "</button>" +
  1059. "</li>" +
  1060. "<li>";
  1061. lines.push({id:idButton, each:each});
  1062. });
  1063.  
  1064. var idButtonPlus = getId();
  1065. var idInputKey = getId();
  1066. innerHTML +=
  1067. "<input class=\"profile-biography\" id=\"" + idInputKey + "\" type=\"text\" style=\"height: 30px;\"/>" +
  1068. "<button id=\"" + idButtonPlus + "\">" + imgEdit + "</button>" +
  1069. "</li>";
  1070.  
  1071. container.innerHTML = innerHTML;
  1072.  
  1073. lines.forEach(function (line, i) {
  1074. var button = document.getElementById(line.id);
  1075. button.style.backgroundColor = "Transparent";
  1076. button.style.border = "none";
  1077.  
  1078. button.onclick = function() {
  1079. bansRegex.splice(i, 1);
  1080. localStorage.setItem("bansRegex", JSON.stringify(bansRegex));
  1081. createConfigTopic(container);
  1082. };
  1083. });
  1084.  
  1085.  
  1086. var buttonPlus = document.getElementById(idButtonPlus);
  1087. buttonPlus.style.backgroundColor = "Transparent";
  1088. buttonPlus.style.border = "none";
  1089.  
  1090. buttonPlus.onclick = function() {
  1091. bansRegex.push(document.getElementById(idInputKey).value);
  1092. localStorage.setItem("bansRegex", JSON.stringify(bansRegex));
  1093. createConfigTopic(container);
  1094. };
  1095.  
  1096. }
  1097.  
  1098. function createConfigBannis(container) {
  1099.  
  1100. var lines = [];
  1101. var idButtonPlus = getId();
  1102. var idInputKey = getId();
  1103.  
  1104. var innerHTML =
  1105. // "<li><input class=\"profile-biography\" id=\"" + idInputKey + "\" type=\"text\" style=\"height: 30px;\"/>" +
  1106. // "<button id=\"" + idButtonPlus + "\">" + imgEdit + "</button>" +
  1107. // "</li>"+
  1108. "<ul style=\" columns: 3; -webkit-columns: 3; -moz-columns: 3;\">";
  1109.  
  1110. banProfiles.forEach(function (each) {
  1111. var idButton = getId();
  1112. innerHTML +=
  1113. "<li>"+
  1114. each.name + " / " + each.rank + space +
  1115. "<button id=\"" + idButton + "\">" + imgDelete + "</button>" +
  1116. "</li>";
  1117. lines.push({id:idButton, each:each});
  1118. });
  1119. innerHTML += "</ul>";
  1120. container.innerHTML = innerHTML;
  1121.  
  1122. lines.forEach(function (line, i) {
  1123. var button = document.getElementById(line.id);
  1124. button.style.backgroundColor = "Transparent";
  1125. button.style.border = "none";
  1126.  
  1127. button.onclick = function() {
  1128. banProfiles.splice(i, 1);
  1129. localStorage.setItem("banProfiles", JSON.stringify(banProfiles));
  1130. createConfigBannis(container);
  1131. };
  1132. });
  1133.  
  1134.  
  1135. // var buttonPlus = document.getElementById(idButtonPlus);
  1136. // buttonPlus.style.backgroundColor = "Transparent";
  1137. // buttonPlus.style.border = "none";
  1138.  
  1139. // buttonPlus.onclick = function() {
  1140. // banProfiles.push({reg:document.getElementById(idInputKey).value, res:document.getElementById(idInputValue).value});
  1141. // localStorage.setItem("banProfiles", JSON.stringify(banProfiles));
  1142. // createConfigBannis(container);
  1143. // };
  1144. }
  1145.  
  1146. function updatePhotoProfil(src) {
  1147. if (src.trim().length === 0) {
  1148. if (profilUsers[currentProfile]) {
  1149. delete profilUsers[currentProfile].pdp;
  1150. localStorage.setItem("profilUsers", JSON.stringify(profilUsers));
  1151. }
  1152. } else {
  1153. updateProfilUser("pdp", src.trim());
  1154. }
  1155. document.getElementsByClassName("profile-avatar")[0].children[0].src = src;
  1156. }
  1157.  
  1158. function renameProfil(name) {
  1159. if (name.trim().length === 0) {
  1160. if (profilUsers[currentProfile]) {
  1161. delete profilUsers[currentProfile].name;
  1162. localStorage.setItem("profilUsers", JSON.stringify(profilUsers));
  1163. }
  1164. name = currentProfile;
  1165. } else {
  1166. updateProfilUser("name", name.trim());
  1167. }
  1168. document.getElementsByClassName("profile-title")[0].children[0].innerHTML = name;
  1169. }
  1170.  
  1171. function colorizeProfil(color) {
  1172. document.getElementsByClassName("profile-title")[0].children[0].style.color = color;
  1173. updateProfilUser("color", color);
  1174. document.getElementById("idProfilColor").style.backgroundColor = color;
  1175. }
  1176.  
  1177. function updateProfilUser(property, value) {
  1178. if (!profilUsers[currentProfile]) {
  1179. profilUsers[currentProfile] = {};
  1180. }
  1181. profilUsers[currentProfile][property] = value;
  1182. localStorage.setItem("profilUsers", JSON.stringify(profilUsers));
  1183. }
  1184.  
  1185. function favProfile(color) {
  1186. console.log("favProfile : " + currentProfile + ", color : " + colorListProfil[color]);
  1187.  
  1188. var index = -1;
  1189. for(var i = 0; i < favProfiles.length; ++i) {
  1190. if (stringContents(favProfiles[i].name, currentProfile)) {
  1191. index = i;
  1192. break;
  1193. }
  1194. }
  1195.  
  1196. if (index !== -1) {
  1197. favProfiles.splice(index, 1);
  1198. localStorage.setItem("favProfiles", JSON.stringify(favProfiles));
  1199. }
  1200.  
  1201. if (color !== "0") {
  1202. favProfiles.push({name:currentProfile, color:color});
  1203. localStorage.setItem("favProfiles", JSON.stringify(favProfiles));
  1204. }
  1205.  
  1206. document.getElementById("idFavColor").style.backgroundColor = colorListProfil[color];
  1207. }
  1208.  
  1209. function banProfile(rank) {
  1210. console.log("banProfile : " + currentProfile + ", rang : " + rank);
  1211.  
  1212. var index = -1;
  1213. for(var i = 0; i < banProfiles.length; ++i) {
  1214. if (stringContents(banProfiles[i].name, currentProfile)) {
  1215. index = i;
  1216. break;
  1217. }
  1218. }
  1219.  
  1220. if (index !== -1) {
  1221. banProfiles.splice(index, 1);
  1222. localStorage.setItem("banProfiles", JSON.stringify(banProfiles));
  1223. }
  1224.  
  1225. if (rank !== "non") {
  1226. banProfiles.push({name:currentProfile, rank:rank});
  1227. localStorage.setItem("banProfiles", JSON.stringify(banProfiles));
  1228. }
  1229.  
  1230. detailRankProfile(rank);
  1231. }
  1232.  
  1233. function detailRankProfile(rank) {
  1234. var innerHTML;
  1235. if (rank === "0") {
  1236. innerHTML = "Ses sujets sont supprimés.";
  1237. } else if (rank === "1") {
  1238. innerHTML = "Ses sujets sont supprimés et ses messages sont masqués.";
  1239. } else if (rank === "2") {
  1240. innerHTML = "Ses sujets et messages sont supprimés.";
  1241. } else {
  1242. innerHTML = "Non banni.";
  1243. }
  1244.  
  1245. document.getElementById("idBanRankDetail").innerHTML = innerHTML;
  1246. }
  1247.  
  1248. //-----------------------------------------------------
  1249. // Messagerie
  1250. //-----------------------------------------------------
  1251.  
  1252. function traiterMessagerie() {
  1253. var button = document.getElementsByClassName("btn btn-danger")[0];
  1254. if (!button) {
  1255. return;
  1256. }
  1257. button.parentElement.onsubmit = function() {
  1258. return window.confirm("Voulez vous quittez le MP ?");
  1259. };
  1260. }
  1261.  
  1262. //-----------------------------------------------------
  1263. // Utils
  1264. //-----------------------------------------------------
  1265.  
  1266. function createImageButton(idButton, buttonHtml) {
  1267. var button = document.getElementById(idButton);
  1268. button.innerHTML = buttonHtml;
  1269. return button;
  1270. }
  1271.  
  1272. function createComboBox(idParent, list) {
  1273. var sel = document.getElementById(idParent);
  1274. var optionoption = null;
  1275.  
  1276. for(i = 0; i < list.length; i++) {
  1277.  
  1278. optionoption = document.createElement('option');
  1279. optionoption.value = list[i];
  1280. optionoption.innerHTML = list[i];
  1281. sel.appendChild(optionoption);
  1282. }
  1283. return sel;
  1284. }
  1285.  
  1286. function httpGetAsync(theUrl, callback) {
  1287. var xmlHttp = new XMLHttpRequest();
  1288. xmlHttp.onreadystatechange = function() {
  1289. if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
  1290. callback(new DOMParser().parseFromString(xmlHttp.responseText, "text/html"));
  1291. };
  1292. xmlHttp.open("GET", theUrl, true); // true for asynchronous
  1293. xmlHttp.send(null);
  1294. }
  1295.  
  1296. function httpGetApiAsync(path, callback) {
  1297. var xmlHttp = new XMLHttpRequest();
  1298. xmlHttp.onreadystatechange = function() {
  1299. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  1300. callback(JSON.parse(xmlHttp.responseText).data);
  1301. }
  1302. };
  1303. xmlHttp.open("GET", "https://avenoel.org/api/v1/" + path, true); // true for asynchronous
  1304. xmlHttp.send(null);
  1305. }
  1306.  
  1307. function contentsString(list, match) {
  1308. for(var i = 0; i < list.length; ++i) {
  1309. if (stringContents(list[i], match)) {
  1310. return i;
  1311. }
  1312. }
  1313. return -1;
  1314. }
  1315.  
  1316. function getPath() {
  1317. return url + window.location.pathname;
  1318. }
  1319.  
  1320. function designTopButton(button) {
  1321. button.style.color = "white";
  1322. button.style.backgroundColor = "transparent";
  1323. button.style.border = "none";
  1324. }
  1325.  
  1326. function hasProfilLink(elem, name) {
  1327. return stringContents(elem.innerHTML, "https://avenoel.org/profil/" + name + "\"");
  1328. }
  1329.  
  1330. function hasProfilAvatar(elem, name) {
  1331. return stringContents(elem.innerHTML, "alt=\"Avatar de "+ name + "\"");
  1332. }
  1333.  
  1334. function hasUrl(elem, url) {
  1335. return stringContents(elem.innerHTML, "<a href=\"" + url + "\">");
  1336. }
  1337.  
  1338. function stringContents(string, match) {
  1339. return string.indexOf(match) !== -1;
  1340. }
  1341.  
  1342. function addButtonToNavBar(names) {
  1343.  
  1344. var buttons = [];
  1345.  
  1346. if (document.getElementById(names[0]) === null) {
  1347. var navbar = document.getElementsByClassName("nav navbar-nav navbar-links");
  1348. var innerHTML = "";
  1349. names.forEach(function(name) {
  1350. innerHTML += "<li class=\"\"><a><button id=\"" + name + "\" ></button></a></li>";
  1351. });
  1352. navbar[0].innerHTML += innerHTML;
  1353. names.forEach(function(name) {
  1354. designTopButton(document.getElementById(name));
  1355. });
  1356. }
  1357.  
  1358. names.forEach(function(name) {
  1359. buttons.push(document.getElementById(name));
  1360. });
  1361.  
  1362. return buttons;
  1363. }
  1364.  
  1365. function getId() {
  1366. return "id" + id++;
  1367. }
  1368.  
  1369. function getPageFromUrl(url, next) {
  1370. var split = url.split("-");
  1371. if (next) {
  1372. split[1]++;
  1373. }else {
  1374. split[1]--;
  1375. }
  1376. return split.join("-");
  1377.  
  1378. }
  1379.  
  1380. //-----------------------------------------------------
  1381. // Patch
  1382. //-----------------------------------------------------
  1383. //
  1384. // https://avenoel.org/topic/40062-1-api-documentation-de-lapi-davenoel
  1385. // https://pastebin.com/raw/geMuZm39
  1386. var version = "3.5.0";
  1387. // 3.6.0 : Pastebin => Etape 3
  1388. // 3.5.0 : Pastebin => Etape 3
  1389. // + changement des pdp de profil
  1390. // 3.4.0 : Pastebin => https://pastebin.com/raw/aSCAu6hA
  1391. // + changement des noms de profil
  1392. // + changement des couleurs de profil
  1393. // + suppression du controle des caractères ching chong et tamoul
  1394. // 3.3.2 : Pastebin => https://pastebin.com/raw/tHBFbsmW
  1395. // + suppression des caractere tamoul
  1396. // 3.3.1 : Pastebin => https://pastebin.com/raw/L4U0Sd1Z
  1397. // + correction du bug sur les surcharges des boutons
  1398. // 3.3.0 : Pastebin => https://pastebin.com/raw/2RVx8RGc
  1399. // + inifinte scroll
  1400. // + correction bug sur les favoris en citation
  1401. // 3.2.0 : Pastebin => https://pastebin.com/raw/9tfLr09X
  1402. // + correction du bug sur les url avec cuck
  1403. // + le favoris est surligné en rouge quand on est cité
  1404. // 3.1.0 : Pastebin => https://pastebin.com/gFPB9jJA
  1405. // + fin de la gestion des configs des données en cache
  1406. // 3.0.0 : Pastebin => https://pastebin.com/6nFzmeFp
  1407. // + début de la page de config dans le profil
  1408. // + Ajout de la gestion des mots clés éditeur dans le profil
  1409. // 2.6.0 : Pastebin => https://pastebin.com/17GWSM7A
  1410. // + initialisation de la page de configuration de l'appli
  1411. // + ajout du ban de topic par mots clés
  1412. // + optimisation de l'affichage des sujets
  1413. // 2.5.0 : Pastebin => https://pastebin.com/JKKB1RJi
  1414. // + ajout d'une liste de mots clés qui seront transformés dans l'éditeur.
  1415. // 2.4.0 : Pastebin => https://pastebin.com/JCfGHLZ4
  1416. // + ajout des dialogs de confirmation pour la suppression des topics/messages et ignorer.
  1417. // + ajout des modifs dans la notifs des patchs.
  1418. // 2.3.0 : Pastebin => https://pastebin.com/QXe2AJ6v
  1419. // + Ajout d'une popup de confirmation pour quitter les MP
  1420. // 2.2.0 : Pastebin => https://pastebin.com/0gPthPD4
  1421. // + ajout d'un bouton pour afficher/masquer toutes les citations.
  1422. // + amélioration de l'affichage de la nouvelle version
  1423. // 2.1.0 : https://pastebin.com/T2dP5ryX
  1424. // + controle de la version
  1425. // + affichage du nombre de postes dans les favoris depuis la dernière visite
  1426. // + controle de la version
  1427. // + affichage du nombre de postes dans les favoris depuis la dernière visite
  1428. // 2.0.8 : Pastebin => https://pastebin.com/21a6u01a
  1429. // + correction du bug sur les citations (redirection bas de page)
  1430. // 2.0.7 : Pastebin => https://pastebin.com/cD6VqLUY
  1431. // + correction d'un bug sur la barre des favoris
  1432. // + ajout de nouvelles actions dans l'éditeur de texte
  1433. // + la barre des courriers est rafraichie toutes les 30s
  1434. // 2.0.6 : Pastebin => https://pastebin.com/GvTLjLaF
  1435. // + l'élément favoris/courrier se déplace avec le scroll
  1436. // 2.0.5 : Pastebin => https://pastebin.com/pNqRphzh
  1437. // + ajout du nombre de courriers non lus sur l'onglet
  1438. // + possibilité d'afficher/masquer les citiations (masquées par défaut)
  1439. // 2.0.4 : Pastebin => https://pastebin.com/4mCdppfi
  1440. // + affichage de la liste des favoris dans les topics noirs
  1441. // + correction bug sur les BL
  1442. // + optimisation des listes
  1443. // 2.0.3 : Pastebin =>https://pastebin.com/nPvLrBbV
  1444. // + correction du bug d'affichage des courriers
  1445. // 2.0.2 : Pastebin => https://pastebin.com/haqi3XRa
  1446. // + Modification du bouton pour afficher/masquer
  1447. // 2.0.1 : Pastebin => https://pastebin.com/vNmgUrCs
  1448. // + Le clique sur le favoris emmene à la dernière page
  1449. // 2.0.0 : Pastebin => https://pastebin.com/eHCt5h8E
  1450. // + Prise en compte de la liste de favoris (affichage reste à droite)
  1451. // L'icone du fichier n'est pas encore mise
  1452. // + Changement du bouton afficher/masquer un commentaire.
  1453. // 1.1.0 : Pastebin => https://pastebin.com/85F6ydsC
  1454. // + gestion de la lovelist sur les profils
  1455. // + plus besoin d'aller dans le code pour gérer ses listes
  1456. // 1.0.3 : Pastebin => https://pastebin.com/RNWPdyyF
  1457. // + suppression de 'Courriers' quand la liste est vide
  1458. // + gestion de la banlist sur les profils
  1459. // 1.0.2 : https://pastebin.com/TJzUnw69
  1460. // + ajout de la liste des messages non lus au niveau de la barre des favs
  1461. // 1.0.1 : https://pastebin.com/mFv7z7wb
  1462. // + correction du bug des bans de topics
  1463. // + detection du favoris/ban à chaque page du topic
  1464. // 1.0.0 : https://pastebin.com/bjVmYYgM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement