0

I’ve been attempting to automate a Craigslist posting (to the extent that it’s possible) by feeding Javascript into the Chrome console:

//load first page
window.location = 'https://post.craigslist.org/k/5Oqq-EfV5hGVjvGSKaEAUw/qZkca?s=edit;'
document.addEventListener("DOMContentLoaded");  

//contact info
document.getElementById("FromEMail").value = "some text";
document.getElementById("ConfirmEMail").value = "some text";
document.getElementById("contact_phone").value = "1234567890";
document.getElementById("contact_name").value = "some text";
document.getElementById("contact_phone_ok").value = "";

//posting title/body
document.getElementById("PostingTitle").value = "some text"
document.getElementById("Ask").value = "00.00"
document.getElementById("postal_code").value = "12345"
document.getElementById("PostingBody").value = "some text"

//posting details
document.getElementById("sale_manufacturer").value = "some text"
document.getElementById("sale_model").value = "some text"
document.getElementById("serial_number").value = "123456789"
document.getElementById("sale_size").value = ""
document.getElementById("language").value = "0"
document.getElementById("condition").value = "0"

//show on maps
document.getElementById("xstreet0").value = "some text"
document.getElementById("xstreet1").value = "some text"
document.getElementById("city").value = "some text"
document.getElementById("region").value = "some text"

//proceed to next page
document.getElementsByTagName('button')[0].click();
document.addEventListener("DOMContentLoaded");

//proceed to third page 
document.getElementsByTagName('button')[0].click(); 
document.addEventListener("DOMContentLoaded");

Text field elements, radio buttons and check boxes were easy, but Craigslist uses something called plupload to handle image uploading and the plupload API site (http://www.plupload.com/docs/v2/API) has not been helpful. Here is the HTML for the plupload image uploader:

 <div id="uploader">
    <form class="add" action="https://post.craigslist.org/k/BIOSUwrr5hGSO_GSKaEAUw/gj9Hz" method="post" enctype="multipart/form-data">
        <input type="hidden" name="cryptedStepCheck" value="U2FsdGVkX18xMjcwMDEyN0ACdPF4GuiG4yXOjXAx9kKHFAp4U_yK9Ut3e0DDAox8yZL-hM3X97M">
        <input type="hidden" name="a" value="add">
        <input type="file" name="file" multiple>
        <button class="addbtn" type="submit" name="go">add image</button>
    </form>
        <button id="plupload" class="newupl disabled" disabled>Add Images</button>
        <div class="draggable-only newupl disabled">You can also drop image files here to upload them</div>
        <a class="newupl" id="classic" href="https://post.craigslist.org/k/BIOSUwrr5hGSO_GSKaEAUw/gj9Hz">Use classic image uploader</a>
        <a id="modern" href="https://post.craigslist.org/k/BIOSUwrr5hGSO_GSKaEAUw/gj9Hz">Use modern image uploader</a>
</div>

This attempt was unsuccessful:

document.getElementById("plupload").value = "C:\\........photo.jpg"

How do I use Javascript to upload a picture to Craigslist with plupload?

  • This is why I have a problem with StackOverflow - people are so hasty to say "This question has been answered" without actually thinking about WHAT the user is trying to do. Simply put, **you're wrong**. It is actually possible to do what you want to do, you just need to go about it a slightly different way to bypass the security features. Check out [this answer here](http://stackoverflow.com/questions/15249185/local-chrome-extension-to-set-file-of-input-type-file). Another possible solution would be to use a "macro" controlling your keyboard to auto-fill everything quickly. – Jeremy Iglehart Feb 04 '17 at 19:52
  • You should edit this answer and release the flag - I'll add a few possible answers you can pick from. Tisk tisk charlietfl... Haste makes waste. – Jeremy Iglehart Feb 04 '17 at 19:52

0 Answers0