[Officiel] OnTchat le JVChat like d’Onche

Publicité

Onche reste gratuit grâce à la publicité.

Crée ton compte, tu verras moins de pubs
aideespoir
aideespoir
et aussi j'ai on'chat 0.2 pas update depuis 6jours c'est bon? comment on auto update ?
:Kj_Chat:

Onche Auto Refresh = refresh la page des topaxent toutes les x secondes auto et l'autre script je m'en rappel plus des ses fonctions
:golem_abasourdi:


mais voici son script
// ==UserScript==
// @name Oncheures
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Affichez les heures des posts
// @author Annapurna
// @match onche.org https://onche.org/topic/*
// ==/UserScript==

// Get all message elements with class 'message'
const messages = document.querySelectorAll('.message');

// Get the href content of the first occurrence of the class 'active'
const hrefContent = document.querySelector('.active').href;

// Loop through each message
messages.forEach(message => {
// Find the element with class 'message-date' within this message
const messageDateElement = message.querySelector('.message-date');

// If such an element was found, extract the date and time from its title attribute using a regular expression
if (messageDateElement) {
const originalString = messageDateElement.getAttribute('title');
const regex = /(\d{2}\/\d{2}\/\d{4} à \d{2}:\d{2}:\d{2})/;
const match = regex.exec(originalString);

// If a match was found, create a new div element and set its inner HTML to the extracted date and time
if (match) {
const newLink = document.createElement('a');
const messageID = message.getAttribute('data-id');
newLink.href = hrefContent + '#message_' + messageID;

// Add CSS styles to the new link element
newlink.style.color = '#79bcee';
newlink.style.fontSize = '0.8125rem';

// Set the inner HTML of the link to the extracted date and time
newLink.innerHTML = match[0];

// Find the element with class 'message-infos' within this message and append the new link element to it
const messageInfosElement = message.querySelector('.message-infos');
if (messageInfosElement) {
messageInfosElement.appendChild(newLink);
}
messageDateElement.remove();

// Add a click event listener to the new link that scrolls to the target message and copies its href attribute to the clipboard
newLink.addEventListener('click', event => {
event.preventDefault();
const href = event.target.getAttribute('href');
const targetElement = document.querySelector(href);
if (targetElement) {
targetElement.scrollIntoView({ behavior: 'smooth' });
navigator.clipboard.writeText(href);
console.log('Link copied to clipboard:', href);
}
});
}
}
});
Onchois confirmé de rang argent
Publicité

Onche reste gratuit grâce à la publicité.

Crée ton compte, tu verras moins de pubs
aideespoir
aideespoir
DoYouEvenRace
DoYouEvenRace
c'était pas un problème mais une fonctionnalité
:Risitas_wtf:


que j'ai aussitôt désactivée
:Risitas_wtf:
Comment t'as fait?
:ahiiii:
Onchois confirmé de rang argent
DoYouEvenRace
DoYouEvenRace
aideespoir
aideespoir
Comment t'as fait?
:ahiiii:
vers la ligne 27 du script, tu remplaces avec ça:
if (event.key === "Enter" && event.shiftKey ) {


comme ça il faut appuyer sur shift ET entrée pour envoyer un message
aideespoir
aideespoir
NVM j'utilisais une version outdated
:nez:


// ==UserScript==
// @name On'Chat
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Ajoute un LiveChat sur onche.org comme sur JVChat
// @author NixOS@onche.com
// @match onche.org https://onche.org/topic/*
// @icon www.google.com https://www.google.com/s2[...]4&domain=tampermonkey.net
// @grant none
// ==/UserScript==

(function() {


'use strict';
// CONFIGURATION
const MESSAGES_PER_PAGES = 20;

// Variables for the keyboard event
const textarea = document.querySelector(".textarea");
const button = document.querySelector("input.button");

textarea.addEventListener("keydown", (event) => {
// Check if the pressed key is Enter and the Shift key isn't pressed
if (event.key === "Enter" && !event.shiftKey ) {
// Prevent the default behavior of the Enter key (i.e., inserting a newline)
event.preventDefault();

// Trigger the button click
button.click();
}
});

const fullUrlString = document.querySelector("div.pagination a.active").getAttribute('href');

// The
const rawUrlString = fullUrlString.split('\/').slice(0, -1).join('\/');
let activePage = parseInt(document.querySelector('.active').text, 10);
const allPagesElements = document.querySelectorAll("div.content.pagination div.pagination")[0].querySelectorAll('a');
let currentMessageCount = document.querySelectorAll("div.messages div.message:not(.answer)").length;
let initialMaxPage = parseInt(allPagesElements[allPagesElements.length - 1].text, 10);

console.log("Script is on")
console.log(rawUrlString)


function callMakeRequest() {
makeRequest(rawUrlString + "/" + activePage)
}

function isElementVisible(el) {
const rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}


function makeRequest(url) {
// Create a new XMLHttpRequest object
const xhr = new XMLHttpRequest();

// Define the URL and method of the request
const method = "GET";

// Open the request with the URL and method
xhr.open(method, url);

// Define the callback function to read the response
xhr.onload = function() {
if (xhr.status === 200) {
const response = xhr.responseText;
// console.log(response)
const parser = new DOMParser();
const htmlDocument = parser.parseFromString(response, "text/html"); // Parse the HTML response
let messageCount = htmlDocument.querySelectorAll("div.messages div.message:not(.answer)").length
console.log(htmlDocument.querySelectorAll("div.messages div.message:not(.answer)"))

console.log("Number of text messages:", messageCount);

if (messageCount > currentMessageCount) {
console.log("New message")
let numberOfMessagesToAdd = messageCount - currentMessageCount;
let nodeArray = htmlDocument.querySelectorAll("div.messages div.message:not(.answer)")
let substring = Array.from(nodeArray).slice(messageCount - numberOfMessagesToAdd, messageCount);

// For each elements that we received. We apppend it to the messages
substring.forEach(element => {
document.querySelector('.messages').appendChild(element);
});
currentMessageCount = messageCount;

// If the textarea is visible we scroll
if (isElementVisible(textarea)) {
// execute the action if the element is visible
document.querySelector(".textarea").scrollIntoView({
block: "center",
inline: "nearest",
behavior: "smooth"
});
}


if (currentMessageCount === MESSAGES_PER_PAGES) {
activePage += 1
currentMessageCount = 0
}
}
//console.log(response);
// Replace this with your actual response handling code
}
};

// Send the request
xhr.send();
}
console.log()
if (activePage !== initialMaxPage) { return }
setInterval(callMakeRequest, 2000);
})();// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match [OFFICIEL] JVCHAT POUR ONCHE, DECOUVREZ ON'CHATSalon principalANTOlNEFORUM2
// @icon www.google.com https://www.google.com/s2[...]ns?sz=64&domain=onche.org
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Your code here...
})();
Onchois confirmé de rang argent
Publicité

Onche reste gratuit grâce à la publicité.

Crée ton compte, tu verras moins de pubs
aideespoir
aideespoir
DoYouEvenRace
DoYouEvenRace
vers la ligne 27 du script, tu remplaces avec ça:
if (event.key === "Enter" && event.shiftKey ) {


comme ça il faut appuyer sur shift ET entrée pour envoyer un message
Bien vu merci
:anus:
Onchois confirmé de rang argent
SVER
SVER
Merci mon cle, c'est genial
:shill:
Onchois confirmé de rang argent
Publicité

Onche reste gratuit grâce à la publicité.

Crée ton compte, tu verras moins de pubs
BashoMulin
BashoMulin
Alors peut-être je vais pouvoir migrer
:hap:
Jeune onchois de rang bronze
Nydelia
Nyny La Taraxent
On voit quasiment rien avec le script risibank c'est dommage
Salon principal

En ce moment