Multiple Files Uploader (Bookmarklet)

The bookmarklet for batch uploading multiple files on Wikidot.

How to use / What is bookmarklets?

preview

nd1.png

1

nd2.png

2

code

javascript:(()%3D%3E%7Bvar%20f%3Ddocument.createElement('input')%3Bf.type%3D'file'%3Bf.multiple%3Dtrue%3Bf.style.display%3D'none'%3Bvar%20c%3Ddocument.createElement('ul')%3Bvar%20b%3Ddocument.createElement('button')%3Bb.innerText%3D'upload'%3Bvar%20a%3Ddocument.getElementById('action-area')%3Bvar%20l%3D%5B%5D%3Bf.onchange%3D()%3D%3E%7Ba.style.display%3D'block'%3Ba.innerHTML%3D'%3Ch1%3EFiles%3C%2Fh1%3E'%3Ba.appendChild(c)%3Bfor(var%20_f%20of%20f.files)%7Bvar%20o%3D%7B%7D%3Bo.d%3Dnew%20FormData()%3Bo.d.append('userfile'%2C_f)%3Bo.d.append('page_id'%2CWIKIREQUEST.info.pageId)%3Bo.d.append('action'%2C'FileAction')%3Bo.d.append('event'%2C'uploadFile')%3Bo.d.append('MAX_FILE_SIZE'%2C52428800)%3Bo.n%3Ddocument.createElement('input')%3Bo.n.value%3D_f.name%3Bl.push(o)%3Bvar%20s%3Ddocument.createElement('span')%3Bs.innerText%3D%60(%24%7B~~(_f.size%20%2F%201024)%7Dkb)%60%3Bvar%20i%3Ddocument.createElement('li')%3Bi.appendChild(o.n)%3Bi.appendChild(s)%3Bc.appendChild(i)%3B%7Da.appendChild(b)%3Bwindow.scrollTo(0%2Ca.getBoundingClientRect().top%20%2B%20window.scrollY)%3B%7D%3Bb.onclick%3Dasync()%3D%3E%7Bb.disabled%3Dtrue%3Bb.innerText%3D'uploading...'%3Bfor(var%20_l%20of%20l)%7B_l.d.append('dfilename'%2C_l.n.value)%3B_l.n.disabled%3Dtrue%3B_l.n.style.background%3D'url(http%3A%2F%2Fd3g0gp89917ko0.cloudfront.net%2Fv--3e3a6f7dbcc9%2Fcommon--theme%2Fbootstrap-base%2Fimages%2Fprogress%2Fprogressbar.gif)center%20no-repeat'%3B_l.n.style.color%3D'transparent'%3B%7Dvar%20e%3Dnull%3Bvar%20r%3Dawait%20Promise.all(l.map(v%3D%3E%7Bvar%20f%3Dfetch('%2Fdefault--flow%2Ffiles__UploadTarget'%2C%7Bmethod%3A%20%22POST%22%2Cbody%3A%20v.d%7D)%3Bf.then(async%20r%3D%3E%7Bvar%20t%3Dawait%20r.text()%3Bvar%20s%3Dt.match(%2F%3Cdiv%20id%3D%22status%22%3E(.*%3F)%3C%5C%2Fdiv%3E%2F)%5B1%5D%3Bvar%20x%3D(s%3D%3D'ok')%7C%7C(s%3D%3D'file_exists')%3B(v.n.style.background%3Dx%3F'%23fff'%3A'%23f99'%2Cv.n.style.color%3Dx%3F'%232b2'%3A'%23b01')%3Bx%7C%7C(e%3Ds)%3B%7D)%3Breturn%20f%3B%7D))%3Bb.innerText%3D!e%3F'complete'%3A'error'%3B!e%7C%7Calert(e)%3Bf.remove()%3B%7D%3Bdocument.body.appendChild(f)%3Bvar%20d%3Dnew%20OZONE.dialogs.Dialog()%3Bd.content%3D'%3Cdiv%20class%3D%22title%22%3Estart%20uploading%3C%2Fdiv%3E%3Cdiv%20class%3D%22content%22%3EAre%20you%20sure%20you%20want%20to%20upload%20your%20files%3F%3C%2Fdiv%3E%3Cdiv%20class%3D%22button-bar%22%3E%3Ca%20href%3D%22javascript%3A%3B%22%20onclick%3D%22OZONE.dialog.cleanAll()%22%3ECancel%3C%2Fa%3E%3Ca%20href%3D%22javascript%3A%3B%22%20onclick%3D%22upload_m_f()%22%3EUpload%3C%2Fa%3E%3C%2Fdiv%3E'%3Bd.show()%3Bwindow.upload_m_f%3D()%3D%3E%7Bd.close()%2Cf.click()%2Cwindow.upload_m_f%3D()%3D%3E%7B%7D%7D%3B%7D)()%3Bvoid(0);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License