09-28-2017 09:06 AM
Hello. I have a lot of items for sale on Ebay, and all my descriptions contains links to my other items (all to all relations). When I place a new item, I want to add it to links list in my another listings. It`s a bit annoying to update all my listings manually when I place a new item for sell, so I desided to make a script which helps me to automaticly update all my descriptions.
But problem is: (there I will try to exolain how I do it step by step):
This is a script which I use:
1) This part triggers click on the row it the editor when i use "revise all listings"
document.getElementsByClassName('dt1-dtr')[i].children[1].click(); // GET ROW IN EDITOR TABLE AND CLICK ON IT - this is a row in editor when I click "revise all listings"
2) This part clicks on HTML edit
document.getElementsByClassName('std-lnk')[0].click();
3) Then I update text in my description between tags
myIFrame = document.getElementsByClassName("ifrm")[0]; content = myIFrame.contentWindow.document.body.innerText; newContent = content.replace(/<!--SeeAlso-->[\s\S]*?<!--endSeeAlso-->/, '<!--SeeAlso-->' + newText + '<!--endSeeAlso-->'); myIFrame.contentWindow.document.body.innerText = newContent;
4) But when I trigger click on "Save button", nothing happens, changes is not saving
document.getElementsByClassName('pbtn')[1].click();
As I understand, I should press at least one button on keyboard manually in HTML editor, only after that the changes can be saved. And, as I understand, I can`t programmatically press this button inside an Iframe, which is HTML editor.
So, my question - is there a way to update my descriptrions automatically using javascript from browser terminal, or I'm wrong, and there is a way to improve my script, so it can save my descriptions??
Please, help.
Bogdan
09-28-2017 01:56 PM
I am not a JavaScript whiz, but I'll try.
I'm unclear on your procedure here.
How are you running the script? Are you using something like GreaseMonkey in Firefox?
What invokes and triggers the script?
Where are you starting? Selling manager Active Selling page?
I'm confused on the editing. It sounds like you are using the bulk editor, but then it looks like you are saying that you are iterating through individual listing revisions via the script. It would help if I understood WHERE you are trying to apply that code you posted.
// GET ROW IN EDITOR TABLE AND CLICK ON IT
What editor?
If you can provide a bit more background and context about which editor, and in what mode (bulk or individual) it would help, and then maybe we can move on to the code details. (a screenshot of the editor page might help)
If I'm understanding this, you have a file of html links to all your listings. Every time you add a new listing you add that listing link to the file (manually?). Then you want to replace the list of links in every one of your listings using RegEx with the new list from the file?
Still unsure about what operation and where your operations are happening, but I'm going to point you to an external Autohotkey search and replace script I wrote recently that I use to revise individual listing descriptions. That approach might also work with modification, but not sure.
You might want to take a look at it and see: http://community.ebay.com/t5/Selling/REMOVING-quot-LINKS-quot-from-eBay-listings/m-p/27522643/highli...
Let's see if we can get on the same page here.
09-28-2017 02:22 PM
Is this where you are operating on the listings with the script?
Bulk editor can't do RegEx so forget I said anything about that (if I did). And my Autohotkey Search and replace can't access the edit box either without a mouse click in the edit box the way it is. I think it could be modified to do so, but would also need serious mods to do the "save and next" iterations.
Have to think about that, and how to get the JavaScript to get focus in the edit box.
09-29-2017 10:27 AM
Thanks for answer. I`m using this editor (select all listings and click edit), and RegEx works well there, text is changing. But problem is, when I press on the next row, or click "Save", the changes doesn`t save. And that`s why I should type something in HTML editor manually from keyboard. Only then changes are saving.
09-29-2017 11:49 AM
Ok. I'll look into it further and see if I have any ideas.
10-05-2017 06:01 PM - edited 10-05-2017 06:05 PM
Ok. Looked at it and have some comments. @bodpan
I can't see the listing editor you see, and can't test anything there as a result. You must be using Seller Hub and I use the classic Selling Manager Bulk Editor.
I tried this modified snippet of your code in the Firefox 52 Web Developer console on two of my listings using the bulk editor (see my screenshot above in this thread.) It worked great.
myIFrame = document.getElementsByClassName("ifrm")[0]; var newText="<Zip Code>"; var content = myIFrame.contentWindow.document.body.innerText; myIFrame.contentWindow.document.body.click(); newContent = content.replace(/zipcode/ig, newText); myIFrame.contentWindow.document.body.innerText = newContent; var nada=document.getElementById('but_editolp_saveNextBtn').click(); var nada=document.getElementById('but_editolp_saveCloseBtn').click();
adding myIFrame.contentWindow.document.body.click(); seemed to do the trick.
As you said, the changes did not save unless I included the above click simulation.
(I had to change the submit button "click" at the end to work with my editor's layout - that's the 2 nada lines)
However, you may be right about JS clicks in iframes depending on scope and context. This is new territory for me, and I don't know, but it may be that although it does work from the browser console, but may not work from a GreaseMonkey script or JavaScript Injector* or however you are implementing the script (you didn't say how you are running the script, I can't read all the detail in your screenshot, and don't recognize the browser)
*been meaning to take a look at that addon but haven't yet
I don't have time tonight to look at how this works out if the script is invoked through GreaseMonkey and if the iframe click() fails for security reasons, but will do so tomorrow or soon.
You are on the right track I think.