// ==UserScript==
// @name weaverx
// @version 2024-11-18
// @description bunch of features for basketweavers
// @author ussao
// @match https://basketweavers.im/*
// @grant none
// ==/UserScript==
function handleTimer(cb){
let input = document.querySelector("textarea[name='topic']")
let btn = document.querySelector("button[type='submit']")
if (!input){ // it's inside a thread
input = document.querySelector("textarea[name='reply']")
}
btn.addEventListener("click", (ev)=>{
ev.preventDefault()
let t = Date.now()
let x = new Date(t)
if(cb.checked){
input.value += "\n" + x.toLocaleString()
}
input.parentElement.submit()
})
}
let form = document.querySelector("form[method='POST']")
if (form){
let cb_timer = document.createElement("input")
cb_timer.type = "checkbox"
cb_timer.name = "timer"
let cb_lbl = document.createElement("label")
cb_lbl.htmlFor = "timer"
cb_lbl.textContent = "Add time?"
form.appendChild(cb_lbl)
form.appendChild(cb_timer)
let t = document.createElement("input")
t.type = "file"
t.name = "file"
form.appendChild(t)
handleTimer(cb_timer)
}