Ce sujet a été résolu
Streamable
Vidéo Streamable
Upload des images au format WebP :
Affichage du temps restant avant de pouvoir réupload une image :
Fonctionne sur Tampermonkey
Enjoie
Je suis le forumeur préféré de ton forumeur préféré
il y a 6 mois
Perso j'utilise ça, je peux faitre Ctrl-V et pas de limite de temps
// ==UserScript==
// @name Onche.org Image Upload on Paste
// @namespace
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
https://onche.org/topic/*
// @match
https://onche.org/forum/*
// @icon
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('
https://onche.org/upload', {
method: 'POST',
body: formData,
headers: {
'accept': '*/*',
'origin': '
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;
}
})();
Cum My Fanatics
// ==UserScript==
// @name Onche.org Image Upload on Paste
// @namespace
// @version 0.1
// @description Permet de coller ou de glisser-déposer une image dans la zone de saisie de texte
// @author EvoIa
// @match
// @match
// @icon
// @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('
method: 'POST',
body: formData,
headers: {
'accept': '*/*',
'origin': '
'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;
}
})();
il y a 6 mois
En ligne
215
Sur ce sujet0










