Trade discussion userscript!

Forum Conventions

  • Newbie
  • Posts: 37
  • Trades: 0
Trade discussion userscript!
« on March 26th, 2017, 04:46 AM »
In short, this is pretty much a userscript that sends formatted PMs to users from the offer page. Here's the code!

Code: [Select]
// ==UserScript==
// @name         Discuss Offers
// @namespace    https://alexandra.moe/
// @version      1.0
// @description  Discuss offers with other Lestrade's users using a template. Intended to be used until the comments system is implemented.
// @author       Alexandra antigravities
// @match        https://lestrades.com/offer/*
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    'use strict';
    var templates = {};
   
    // CHANGE TEMPLATES HERE
    templates.Declined = "Hi! I declined your [url={{offer-url}}]offer[/url] because:\n\n{{reason}}\n\nThanks for the offer anyway! Feel free to send me another!\n\n-Alex";
    templates.Accepted = "Hi, I just wanted to discuss something with you about this [url={{offer-url}}]offer[/url]:\n\n{{reason}}\n\nThanks!\n-Alex"
    templates.Unread = templates.Accepted;
    templates.Completed = templates.Completed;
    templates.Canceled = templates.Accepted;
    templates.Pending = templates.Pending;

    var window = unsafeWindow;
    var st = document.getElementsByTagName("h2")[0];
    var oto;
    if( document.getElementsByTagName("strong")[0].children[0].href.toString() == document.getElementById("userbox").children[0].href.toString() ) oto = document.getElementsByTagName("strong")[1].children[0].getAttribute("data-id");
    else oto = document.getElementsByTagName("strong")[0].children[0].getAttribute("data-id");
    var tmpl = templates[st.innerText.split("current status: ")[1]];
    st.innerHTML += "<br><br><input type='text' id='reason'></input><form action='/pm/?sa=send2' method='post'><input type='hidden' name='" + window.we_sessvar + "' value='" + window.we_sessid + "'></input><input type='hidden' name='subject' value='Re: your offer #" + window.location.toString().split("/")[4] + "'></input><input type='hidden' name='recipient_to[]' value='" + oto + "'></input><input type='hidden' id='m_message' name='message' value=\"" +
    tmpl.replace("{{offer-url}}", window.location.toString()) + "\"/><input type='submit' value='Discuss this offer' onclick=\"document.getElementById('m_message').value=document.getElementById('m_message').value.replace('{{reason}}', document.getElementById('reason').value);\"></input></form>";
})();

You can and should change the templates under the "CHANGE TEMPLATES HERE" comment. Mainly wrote this for myself but figured I'd release it in case it helps anyone else out. Have fun, and happy trading!

[Lestrades.com] Nao 尚

  • I'm Share-Locked
  • Administrator
  • Posts: 1,396
  • Trades: 223
Re: Trade discussion userscript!
« Reply #1, on March 26th, 2017, 11:18 AM »
I like how it's just simple and elegant, a good replacement while you wait for me to get back to work. ;)
Re: Trade discussion userscript!
« Reply #2, on March 27th, 2017, 12:49 AM »
Hey, I think it'd be a good opportunity to ask... What do you think would be good 'stock' reasons for declining an offer?
Barter has a few ones, added 'Not worth it to me' per request, but I feel like there must be more, like 'I'm not feeling it', or 'I have trouble finding my keys'. Or even, variations on the 'unfair' reply, such as 'I think it's a bit unbalanced' or 'This is grossly unbalanced, you monster!'

I'd like to keep my (our) options open.

PS: considering that I'm showing Canceled offers (possibly for just a few days before I remove them automatically), I could also add a 'reason for canceling'... I mean, sometimes I see a cancel and I just wonder why! I canceled an offer today and regretted not being to explain why.