// ==UserScript== // @name jvc message history // @namespace http://tampermonkey.net/ // @version 0.1 // @description add user message history in jvc // @author Yhria // @match https://www.jeuxvideo.com/profil/* // @icon https://www.google.com/s2/favicons?domain=google.com // @grant GM_xmlhttpRequest // @downloadURL none // ==/UserScript== var result; function parseHeaders(headersString) { class Headers { get(key) { return this[key.toLowerCase()]; } } const headers = new Headers(); for (const line of headersString.split("\n")) { const [key, ...valueParts] = line.split(":"); // last-modified: Fri, 21 May 2021 14:46:56 GMT if (key) { headers[key.trim().toLowerCase()] = valueParts.join(":").trim(); } } return headers; } function last_5messages(username){ GM_xmlhttpRequest({ method: 'GET', url: 'https://jvarchive.com/api/auteurs/' + username + '/last5messages', synchronous: true, headers: { "accept": "application/json", "accept-language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ko;q=0.6,ja;q=0.5", "cache-control": "no-cache", "pragma": "no-cache", "sec-ch-ua": "\"Chromium\";v=\"94\", \"Google Chrome\";v=\"94\", \";Not A Brand\";v=\"99\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin" }, onload: function(responseDetails) { result = JSON.parse(responseDetails.responseText); add_message_history() } }); } function add_message_history(){ let node = document.getElementsByClassName("bloc-default-profil"); let x; let child; let username; let to_add; let d; for (x in node) { if (!isNaN(x)) { if (node[x].childElementCount > 0) { for (child in node[x].children) { if (node[x].children[child].className == 'header') { if (node[x].children[child].children[0].localName == 'h2') { if (node[x].children[0].children[0].textContent == 'Derniers messages forums') { return 0 } } } } } } }console.log("as"); console.log(x); console.log(node); if (result.statusCode === undefined){ to_add = `