InscriptionConnexion
Streamable
Vidéo Streamable

Upload des images au format WebP :

gist.githubusercontent.com https://gist.githubuserco[...]che.upload-images-webp.js

Affichage du temps restant avant de pouvoir réupload une image :

gist.githubusercontent.com https://gist.githubuserco[...].cooldown-upload-image.js

Fonctionne sur Tampermonkey
:singelunettes:


Enjoie
:chat_pouce:
Je suis le forumeur préféré de ton forumeur préféré
:pouet:
il y a 6 mois
Je vais essayer, merci crayolat
:selectionchampi:
il y a 6 mois
Up
:singelunettes:
Je suis le forumeur préféré de ton forumeur préféré
:pouet:
il y a 6 mois
Non désolé
:singelunettes:
Je suis le forumeur préféré de ton forumeur préféré
:pouet:
il y a 6 mois
Perso j'utilise ça, je peux faitre Ctrl-V et pas de limite de temps
:Golem_velo:


// ==UserScript==
// @name Onche.org Image Upload on Paste
// @namespace onche.org https://onche.org/
// @version 0.1
// @description Permet de coller ou de glisser-déposer une image dans la zone de saisie de texte
// @author EvoIa
// @match onche.org https://onche.org/topic/*
// @match onche.org https://onche.org/forum/*
// @icon www.google.com https://www.google.com/s2[...]...]z=64&domain=onche.org
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Ajoute un event listener à la zone de saisie de texte
const textArea = document.querySelector('.textarea[name="message"]');
if (!textArea) return;

textArea.addEventListener('paste', handleImagePaste);

function handleImagePaste(event) {
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
for (let i = 0; i < items.length; i++) {
if (items[i].kind === 'file') {
const file = items[i].getAsFile();
uploadImage(file);
}
}
}

function uploadImage(file) {
if (!file || !file.type.startsWith('image/')) return;

const formData = new FormData();
const token = document.querySelector('#topic').dataset.token;
formData.append('file', file);
formData.append('token', token);

fetch('onche.org https://onche.org/upload', {
method: 'POST',
body: formData,
headers: {
'accept': '*/*',
'origin': 'onche.org https://onche.org',
'referer': window.location.href
}
})
.then(response => response.json())
.then(data => {
if (data.status === 'done' && data.image) {
const imageCode = `[img:${data.image}]`;
insertTextAtCursor(textArea, imageCode);
}
})
.catch(error => console.error('Erreur lors du téléchargement de l\'image :', error));
}

function insertTextAtCursor(textArea, text) {
const start = textArea.selectionStart;
const end = textArea.selectionEnd;
textArea.value = textArea.value.substring(0, start) + text + textArea.value.substring(end);
textArea.selectionStart = textArea.selectionEnd = start + text.length;
}
})();
:jmlp-onche:
Cum My Fanatics
:pascal_nrv:
il y a 6 mois