Topic: Filling the upload form with a userscript

Posted under e621 Tools and Applications

On the New Upload page
I want to fill the File URL, Sources and Description fields with a Tampermonkey script.

Something like this:

// ==UserScript==
// @name         e621 upload test
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Fills the e621 upload form
// @author       Mantikor
// @match        https://e621.net/uploads/new
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let element_url = document.querySelector("div.flex-grid:nth-child(3) > div:nth-child(2) > div:nth-child(2) > label:nth-child(1) > input:nth-child(1)");
    element_url.value = "https://d.furaffinity.net/art/fender/1284661300/1284661300.fender_fender.png";

    let element_source = document.querySelector(".upload-source-row > input:nth-child(1)");
    element_source.value = "https://www.furaffinity.net/view/4483888/";

    let element_description = document.querySelector("#post_description");
    element_description.value = "Test Test Test";
})();

Problem:
When I click inside the Artists field and start typing, the File URL and Description disappear.
And when I click the Plus button to the right of the Source field, the source disappears.

How can I make this work?
So far, my solution involves "focus" event handlers that put text in the clipboard, and the user pastes it manually.

edit:
I know about the e621 API.
But I want to use the existing upload form, not make my own.

There are a few parameters the upload page can use to prefill the fields. Instead of filling them via js you would just use the userscript to redirect the user to the appropriate url.

In this case it would be https://e621.net/uploads/new?upload_url=https://d.furaffinity.net/art/fender/1284661300/1284661300.fender_fender.png&sources=https://www.furaffinity.net/view/4483888&description=Test%20Test%20Test

These are all the parameters you can use:
upload_url, parent, description, sources, tags. Multiple sources need to be comma-seperated, tags are space seperated. There's also rating_locked and locked_tags which can be used when the user has the appropriate permissions for those.

The uploader uses vue internally which is why the changes you made via the userscript were not persisted correctly.

To elaborate on what Earlopain has said. Vue maintains an internal copy of the data and uses that to update the visual copy. This is driven by input events to the fields, not by the dom element itself. You can "fix" your script by having it emit input events to the field. This is only guaranteed to work if the page has fully loaded, so some form of waiting for content ready and then a few ms would be needed.

The better fix here is to use the provided fill options within the script for the various fields.

mantikor said:
edit:
I know about the e621 API.
But I want to use the existing upload form, not make my own.

If you are referring to Earlopain's response, it sounds like you don't need to mess with the API at all. It's just URL parameters. So instead of activating your script on the uploads page itself, you would activate it for example on an Inkbunny page, and launch a new page with the appropriate values filled in on the url.

For example, to upload Mirror Twi from Inkbunny, you would generate the url https://e621.net/uploads/new?upload_url=https://va2.ib.metapix.net/files/full/3815/3815888_ColdBloodedTwilight_twimirror.png&sources=https://inkbunny.net/s/2586357&description=Please%20consider%20supporting%20my%20SubscribeStar:%20the%20Tower%20of%20Stars

Something like

let source = get_current_url();
let upload_url = get_image()['href'];
let description = get_description().innerHTML;

let built_url = 'https://e621.net/uploads/new?' + 'upload_url=' + upload_url + '&sources=' + source + '&description=' + description;
built_url = escape(built_url);

launch_new_tab(built_url);

Thank you for your answers!
With the query string, writing the userscript is almost trivial.

If only converting an FA post description to DText were this easy...
I'll probably use XSLT for that.

kiranoot said: You can "fix" your script by having it emit input events to the field.

To expand on this one, this is how I've been doing it.
https://github.com/bitWolfy/re621/blob/master/src/js/components/utility/UtilEvents.ts#L44-L55

But yeah, that's only needed for fields not filled in by URL parameters. So, tags and such.
And copying those from FurAffinity is a terrible idea.

mantikor said:
If only converting an FA post description to DText were this easy...

Doesn't Idem's Sourcing Suite handle DText in descriptions?
Don't quote me on that, I don't remember for sure.

The URL parameters don't work if the description is very long.

Example:
https://www.furaffinity.net/user/sakda/
https://www.furaffinity.net/view/45134129/
https://d.furaffinity.net/art/sakda/1639981810/1639981810.sakda_2-5_caning.jpg

Idem's Sourcing Suite inserts an "Upload to e621" link on every FA view page.
On the above FA view page, the link is:
(warning, huge URL)

https://e621.net/uploads/new?upload_url=https%3A%2F%2Fd.furaffinity.net%2Fart%2Fsakda%2F1639981810%2F1639981810.sakda_2-5_caning.jpg&sources=https%3A%2F%2Fwww.furaffinity.net%2Fview%2F45134129%2F%2Chttps%3A%2F%2Fd.furaffinity.net%2Fart%2Fsakda%2F1639981810%2F1639981810.sakda_2-5_caning.jpg%2Chttps%3A%2F%2Fwww.furaffinity.net%2Fuser%2Fsakda%2F&description=From+source%3A%0A%5Bsection%3DThe+Public+Lions+5-3%0A+-+by+Sakda+%28+https%3A%2F%2Fwww.furaffinity.net%2Fuser%2Fsakda%2F+%29%5D%0AFrom+left+to+right+%3A+Arthid%2C+Ishaa+and+Sakda+%0A%22BACK%22%3Ahttps%3A%2F%2Fwww.furaffinity.net%2Fview%2F45049436%2F+*********+%22%23%22%3Ahttps%3A%2F%2Fwww.furaffinity.net%2Fview%2F45134129%2F%23+%0A%0Ah3.+Chapter+5+-+Breaking+The+Lions+Plate+3+%5Bi%5D+Whipping+%5B%2Fi%5D+%0A%0ASakda+and+Arthid+were+taken+to+another+room.+Only+few+light+shine+through+it%E2%80%99s+small+window.+There+were+multiple+restraining+rack+across+the+room+one+of+them+was+large+wooden+pillar.+%0A%0ABoth+of+them+had+too+few+power+to+resist.+they+were+both+in+thirst+and+hunger.+Still%2C+they+were+forcefully+taken+to+the+pillar+and+bind+there+with+their+front+closed+to+it+and+their+back+and+buttock+exposed.+Sakda+was+expectiong+what+was+going+to+happened%2C+this+was+a+whipping+position.+%0A%0AWhen+the+lions+were+securely+bound+to+the+post%2C+one+lioness+said+%E2%80%9CTime+to+meet+your+worst+fate%2C+lions.+Have+you+ever+wondered+how+much+pain+you+can+endure%3F%E2%80%9D+She+tucked+his+tail+between+his+thighs+%E2%80%9CKeep+it+there+or+your+tail+will+be+broken%E2%80%9D+Then+they+walked+off+to+guard+the+room+at+the+entrance.+%0A%0AThe+room+was+so+quiet%2C+that+his+whisper+could+be+heard+some+distance+away%2C+Arthid+whispered+to+his+friend+%E2%80%9CHey+Sakda%2C+are+you+afraid.+Don%E2%80%99t+let+them+know+who+you+are%2C+alright%3F+I+will+try+anything+to+divert+their+attention.%E2%80%9D+%0A%0ASakda+shook+his+head+%E2%80%9CIt%E2%80%99s+not+going+to+work%2C+that+lioness%2C+Ishaa%2C+She+knew+about+me%E2%80%9D+%0A%0A%E2%80%9CI%E2%80%99ll+try+anything%2C+I+will+not+let+you+be+sacrificed%E2%80%9D+Arthid+answer+firmly%2C+even+in+his+whisper.+%0A%0A%E2%80%9CThey+must+have+talked+about+the+blood+moon+ritual+up+there.+I%E2%80%99m+scared%E2%80%9D+Sakda+replied+%0A%0AAfter+several+minutes+a+wooden+door+opened+and+a+lioness+came+into+the+room.+She+walked+to+a+rack+nearby.+and+took+out+a+short+leather+whip.+Cracking+is+a+few+times%2C+then+walked+to+the+two+lions.+%0A%0A%E2%80%9CI+want+to+know+how+long+can+you+handle+this%E2%80%9D+Ishaa+said%2C+she+rubbed+her+leather+whip+slowly+against+Sakda+back%2C+causing+an+unpleasurable+anticipation+of+what+will+happened+%E2%80%9CImagine+this+hard+leather+moved+very+fast+to+your+skin...%E2%80%9D+%0A%0AArthid+let+our+a+snarl+%E2%80%9CWhat+ever+you+do%2C+I+will+not+mate+with+any+lioness+here%E2%80%9D+Arthid+was+trying+to+grasp+her+attention%2C+letting+her+focus+on+him+not+Sakda.+He+was+not+sure+if+this+was+working.+%0A%0AIshaa+glared+at+him+%E2%80%9CI%E2%80%99m+not+talking+to+you%2C+slave.+Ten+whip+for+your+insolence+and+let%E2%80%99s+see+if+you+change+your+mind%E2%80%9D+Ishaa+replied.+Unreluctantly%2C+she+swang+her+whip+making+a+whizzing+sound+shortly+it+landed+onto+his+buttock+making+a+loud+crackin.+A+red+strip+was+left+along+the+flesh+where+the+leather+band+hit.+He+screamed+in+great+agony%2C+the+pain+from+whiping+was+rapid%2C+sharp+and+overwhelming.+While+he+was+still+in+the+former+blow+pain%2C+another+blow+was+landed%2C+giving+him+no+time+to+recover.+%0A%0AArthid+tried+to+suppress+his+cry+but+he+couldn%E2%80%99t%2C+blow+after+blow%2C+he+couldn%E2%80%99t+expected+when+was+it+coming.+After+five+whips%2C+his+tears+came+out+spontaneously%2C+he+was+literally+crying.+%0A%0AIshaa+stopped+%E2%80%9CWe%E2%80%99re+just+half+way+here%2C+are+you+crying%2C+not+as+strong+are+you%3F%E2%80%9D+%0A%0A%E2%80%9CIs...is+this+all+you+can+do%2C+SAVAGE%E2%80%9D+Arthid+replied%2C+his+voice+shaking.+%0A%0AAnother+blow+hit+his+back%2C+he+grunted.+The+pain+was+accumulating+until+he+felt+his+entire+back+and+buttock+was+burning+with+extra+hundreds+needles+piercing+him+in+each+blow.+When+the+last+blow+landed.+Arthid+cried+uncontrollably.+His+flesh+got+red+and+swollen+in+multiple+stripes.+Her+whip+was+not+heavy+enough+to+cut+into+his+flesh+though.+%0A%0AHe+said+shaking+%E2%80%9CSo+weak%21%E2%80%9D+%0A%0AIshaa+furiously+delivered+more+blows+to+his+back%2C+It+was+exceeding+ten+already.+In+every+blows+he+let+himself+out+a+painful+grunt+which+get+weaker+after+each+hit.+Now+Arthid+have+no+power+left+to+stand+himself+up%2C+he+dropped+himself+by+his+weight%2C+only+the+restrain+on+his+wrist+make+his+bldy+semi-upright%2C+by+then+she+stopped.+%0A%0AArthid+body+was+down%2C+panting+heavily%2C+he+tried+to+taunt+her+again%2C+but+the+sound+he+made+was+only+incomprehensible+shaking+babblings.+%E2%80%9CY..you+can...do+.bet..eer%E2%80%9D+%0A%0A%E2%80%9CSTOP%21+Why+you+have+to+do+this%E2%80%9D+Sakda+interrupted.+He+was+painfully+watching+his+friend+being+torture+before+him%2C+It+was+even+worse+knowing+he+did+it+on+his+behalf.He+really+don%E2%80%99t+understand+her+at+this+point.+If+what+she+wanted+was+him+to+be+the+offering%2C+why+she+needed+to+tortour+another+lion.+%0A%0AIshaa+panted+by+her+exertion+She+said+%E2%80%9CThat%E2%80%99s+what+you+will+get+when+you+don%E2%80%99t+submit.+I+think+It%E2%80%99s+your+turn+now.+Twenty+whip+for+you+trying+to+bite+me%E2%80%9D+%0A%0AShe+lashed+her+whip+on+Sakda%E2%80%99s+body%2C+eliciting+then+same+kind+of+pain+and+grunt.+He+could+not+stop+himself+tearing+after+several+blows.+After+ten+She+ceased+and+asked+him+her+most+wanted+answer+%E2%80%9CNow%2C+answer+me+who+is+your+mother%2C+failing+to+answer+this+and+I+will+whip+your+friend+more%E2%80%9D+%0A%0ASakda+glanced+to+Arthid+finding+that+he+was+already+looked+at+him.+Arthid+shoke+his+head+in+disagreement.+Sakda+had+to+decide+what+to+do.+It+was+all+about+him%2C+he+thought.+She+would+get+what+she+wanted+whatsoever.+Insisting+not+to+answer+resulted+in+Arthid+being+whipped+more%2C+he+decided.+%0A%0A%E2%80%9CMy+friend%2C+he%E2%80%99s+not+involved+in+this%2C+this+about+you+and+me.+Why+do+you+need+my+answer%2C+if+you+know+it+already%E2%80%9D+Sakda+asked+her.+%0A%0AIshaa+gestered+a+lioness+guard+in+the+room+and+ordered+%E2%80%9CHe%E2%80%99s+done+here.+Take+Arthid+to+Charvi%2C+told+her+she%E2%80%99s+incharge+of+disciplining+him+to+be+a+good+breeder%E2%80%9D+%0A%0AArthid+was+quickly+collared+and+evacuated+out+of+the+room.+With+his+remaining+strength%2C+he+said+his+last+word+before+he+left+%E2%80%9CSavage%21%E2%80%9D+%0A%0AThere+was+no+other+lion+in+the+room+except+Ishaa+and+Sakda.+His+back+was+still+sore+from+the+last+whip.+%0A%0A%E2%80%9CWhat+I+know+is%2C+you+true+mother+might+be+Mali%2C+the+exiled+lioness+long+ago.+Is+that+true%3F%E2%80%9D+%0A%0ASakda+replied+%E2%80%9CWhy+is+it+so+important%3F%E2%80%9D+%0A%0A%E2%80%9CYou+are+here+to+answer%2C+not+asking+more+question%E2%80%9D+She+yelled+and+whipped+him+again+many+times%2C+he+couldn%E2%80%99t+count%2C+until+Sakda+whimpered+in+pain+and+started+to+fell+like+his+counterpart.+%0A%0A%E2%80%9CYou+can+not+tolerate+this+for+long.+ANSWER+ME%21%E2%80%9D+demaned+Ishaa.+%0A%0AHis+back+burning+in+immense+pain%2C+his+body+shaking%2C+tears+dropped+from+his+eyes.+his+mouth+grasped+trying+to+breath+normally.+He+could+only+spoke+word+by+word+with+trembling+voice+%E2%80%9C+You..+will..+get+nothing....tortouring...me...%E2%80%9D+%0A%0AIshaa+sighed+%E2%80%9CIt+seemed+I+don%E2%80%99t+whip+hard+enough.+I+will+find+a+lioness+who+will+surely+whip+words+out+of+your+intractable+mouth%E2%80%9D+%0A%0AAs+she+said%2C+she+walked+out+of+the+room%2C+leaving+him+alone+with+his+sore+back.+Sakda+heard+a+door+shut+behind+him.+When+he+knew+she+was+gone%2C+he+dropped+himself%2C+trying+to+comfort+his+body+even+a+bit.+His+mind+wondered+what+she+will+do+next.+She+might+just+hit+him+harder%2C+which+can%E2%80%99t+get+worse.+He+hoped+the+pain+would+be+unbearable+till+he+eventually+fainted.+%0A%0AAfter+several+minutes%2C+The+door+swang+again%2C+this+time+Ishaa+brought+back+one+lioness.+She+said+to+her+%E2%80%9CHere+I+will+show+you+how+to+tame+the+most+stubborn+lion%E2%80%9D.+The+lioness+grasped+when+she+saw+what%E2%80%99s+before+her%3A++it%E2%80%99s+a+lion+bound+to+a+wooden+post%2C+half+standing+half+sitting%2C+with+many+red+stripes+from+whipping.+The+lion+himself+breathing+heavily+from+pain.+%0A%0A%E2%80%9CMajjari%3F%E2%80%9D+Sakda+tried+to+make+his+word.+He+couldn%E2%80%99t+mistaken%2C+her+voice+and+scent+was+familiar+to+him.+%0A%0A%E2%80%9CLook+at+him%2C+he%E2%80%99s+in+no+good+condition+but+still+doesn%E2%80%99t+submit%2C+how+tolerance%E2%80%9D+Ishaa+said%2C+whipping+him+a+few+time.+Sakda+didn%E2%80%99t+expecting+it+thus+he+screamed+in+pain.+%E2%80%9CYou+are+here+to+learn+how+to+make+a+lion+submit.+Here+take+this+whip+and+hit+him+until+he+answer%E2%80%9D+She+handed+her+whip+to+Majjari+and+then+turned+to+Sakda+%E2%80%9CI+will+ask+you+for+one+last+time%2C+who+is+your+mother%E2%80%9D+%0A%0A%E2%80%9CI+won%E2%80%99t+tell+you%E2%80%9D+Sakda+said+tiring+and+hurt.+He+panted+heavily+under+the+embrace+of+his+own+arms+and+wooden+post.+He+didn%E2%80%99t+care+what+would+happen.+It+would+be+worst+the+either+ways+%0A%0AMajjari+stood+there+clencing+her+fists.+She+didn%E2%80%99t+hit+the+lion+as+the+mistress%E2%80%99+command.+Ishaa+coaxed+her+%E2%80%9CWhip+him+Majjari%2C+show+this+lion+who+is+his+mistress%E2%80%9D+%0A%0A%E2%80%9CNo%2C+look+how+he%E2%80%99s+beaten.+How+could+you+do+this%3F%2C+this+is+cruel.+You+cannot+do+this+to+him%2C+he%E2%80%99s+a+public+slave.+You+cannot+tortour+him+without+public+agreement%E2%80%9D+Answered+Majjari%2C+she+tried+to+make+her+voice+apathy%2C+but+inside+she+was+burning+with+anger%3B+that+was+her+brother%2C+beaten+mercilessly.+%0A%0A%E2%80%9CListen+Majjari%2C+I+suspected+this+lion+is+the+candidate+to+be+sacrificed+at+this+upcoming+blood+moon.+His+mother%2C+might+be+a+former+lioness+here+name+Mali.+If+not+why+is+he+hiding%2C+he+must+have+known+something+about+our+ritual+so+he+tried+to+conceal+it%E2%80%9D+Ishaa+told+her+%E2%80%9CDo+it+Majjari+we+need+to+know+directly+from+his+own+words%E2%80%9D+%0A%0AMajjari+stood+still+%E2%80%9CI+always+consider+you+as+my+mother%2C+my+kind+Ishaa%2C+is+she+gone%3F+You%E2%80%99re+so+cruel+now%2C+what+happened%3F%E2%80%9D+she+said%2C+her+voice+shaking%2C+almost+crying.+%0A%0A%E2%80%9CLet+me+tell+you+something.+If+that+is+true+he%E2%80%99s+the+son+of+Mali%2C+he%E2%80%99s+not+even+a+slave%2C+he%E2%80%99s+at+his+best+an+offering.+As+you+know+an+offering+have+nothing+to+do+with+the+public%2C+it+belongs+to+us%E2%80%9D+Ishaa+tried+to+persuade+her+%E2%80%9CNow+take+this+whip+and+lash+him+hard%2C+make+him+submit.+The+blood+moon+is+near.+We+need+to+solve+this+issue+fast+so+we+can+move+on+to+our+preparation%E2%80%9D+%0A%0AMajjari+looked+her+in+the+eyes+%E2%80%9CI+will+show+you+how+to+make+a+lion+submit%E2%80%9D+she+said+hen+went+to+Sakda+and+touched+his+swollen+flesh+in+pity+%E2%80%9CYou+must+be+hurt+so+bad%E2%80%9D+She+whispered.+Then+she+stroked+and+licked+his+face+trying+to+comfort+him.+The+only+thing+Sakda+could+do+in+response+is+whimpering+and+sobing.+His+pain+did+decrease.+%0A%0A%E2%80%9CYou+don%E2%80%99t+have+to+do+this%E2%80%9D+Sakda%E2%80%99s+voice+was+fainted+and+shaking+%0A%0AMajjari+continued+stroking+his+face+%E2%80%9CIt%E2%80%99s+over+Sakda%2C+She+knew+it+and+she+will+sacrifice+you%E2%80%9D+whispered+her.+%0A%0A%E2%80%9CWhat+can+I+do+now%3F%E2%80%9D+Sakda+asked.+%0A%0A%E2%80%9CNothing%2C+but+I+promise+I+will+help+you+as+much+as+I+can%E2%80%9D+Majjari+replied.+%0A%0AThen+she+stood+up+and+face+Ishaa+%E2%80%9CI%E2%80%99m+tried+of+playing+your+game+ishaa.+So+you+want+to+know+the+answer+so+much%3F+Fine+I+will+tell+you%2C+that+lion%E2%80%99s+mother+is+the+same+as+mine%2C+Mali%2C+my+true+mother.+I+knew+it%2C+but+not+from+you.+And+so+at+this+moment+you+wanted+me+to+whip+my+own+brother%2C+SAVAGE%21%E2%80%9D+She+throw+the+whip+to+the+corner+of+the+room.+Majjari+could+no+more+control+her+temper.+Tears+accumulating+under+Majjari%E2%80%99s+eye+lid%2C+her+voice+was+shaking+%E2%80%9CYou%E2%80%99re+not+the+kind+mother+I+know%E2%80%9D+then+she+walked+out+the+door%2C+Knowing+there+was+no+more+she+could+do.+%0A%0AIshaa+told+Sakda+%E2%80%9CWell+lion%2C+thanks+to+your+sister%2C+we%E2%80%99re+done+here.+but+that+doesn%E2%80%99t+mean+your+pain+is+ended.+You+will+be+tortour+until+your+spirit+is+broken+and+let+see+if+you+want+to+live+altogether%E2%80%9D+then+she+walked+out+of+the+room%2C+leaving+him+tied+to+the+post.+%0A%0AEven+if+she+tried+express+any+feeling%2C+Ishaa+was+dissapointed+she+was+called+savage+three+times+in+a+row%3B+one+even+by+her+own+step+daughter.+She+sighed+and+decided+she+need+no+more+from+Sakda+at+the+moment%2C+but+now+she+had+a+good+news+for+the+pristress+council.%0A%5B%2Fsection%5D&tags

This leads to an error page on e621:
414 Request-URI Too Large

But that's not a big deal, because ISS also adds a "Copy Description" button to every FA view page.

Updated

Nginx limits URLs to 8KB (8192 characters) by default, otherwise you'll get the aforementioned error. The error comes from openresty which itself is based on nginx.

earlopain said:
Nginx limits URLs to 8KB (8192 characters) by default, otherwise you'll get the aforementioned error. The error comes from openresty which itself is based on nginx.

Thanks, I'll ask Idem to include an "Upload to e621 without description" link.

  • 1