-
-
Save jackm/c0e4b3e6b2d3965f21387e00a0068c7b to your computer and use it in GitHub Desktop.
| // ==UserScript== | |
| // @name Kijiji Repost Ad Simple | |
| // @namespace KijijiScripts | |
| // @version 0.3.1 | |
| // @description Allows for easy and free ad reposting on Kijiji when managing your ads. A new link named "Repost Ad" will appear in the ad manage widget as well as on the My Kijiji page for each ad. | |
| // @match http://www.kijiji.ca/v-view-details.html?* | |
| // @match https://www.kijiji.ca/v-view-details.html?* | |
| // @match https://www.kijiji.ca/m-my-ads.html* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Add link to the page if the ad manage widget exists | |
| // (ie. they are viewing their own ad under their control) | |
| if (document.querySelector('#ManageAdWidget') && Kj.extVars.adId) { | |
| var li = document.createElement('li'); | |
| li.className = "divider"; | |
| li.innerHTML = "|"; | |
| var a = document.createElement('a'); | |
| a.href = "p-edit-ad.html?submitType=repostAd&adId=" + Kj.extVars.adId; | |
| a.innerHTML = "Repost Ad"; | |
| document.querySelector('#ManageAdWidget ul.vertical-ul').appendChild(li); | |
| document.querySelector('#ManageAdWidget ul.vertical-ul').appendChild(document.createElement('li').appendChild(a)); | |
| } | |
| // Add link to "My Kijiji" ad management page for each ad listed | |
| else if (document.querySelector('#PageMyKijiji > div.ng-scope')) { | |
| // Must wait for page to load first otherwise querySelector won't find any of the ads | |
| // For some reason adding an event listener for the window "load" event doesn't work, so we have to use a hackish timeout instead | |
| setTimeout(function() { | |
| var adIds = document.querySelectorAll('div.item-enabled.ResultAdRow.table-row.ng-scope'); | |
| for (var i = 0; i < adIds.length; i++) { | |
| var a = document.createElement('a'); | |
| a.href = "p-edit-ad.html?submitType=repostAd&adId=" + adIds[i].getAttribute('data-ad-id'); | |
| a.setAttribute('data-ng-click', "repostItem(item)"); | |
| a.innerHTML = "Repost"; | |
| adIds[i].querySelector('div.cta-other').appendChild(a); | |
| } | |
| }, 1000); | |
| } | |
| })(); |
Hi,
Kijiji updated their site and this repost gist doesn't work anymore. Too bad , it was very helpfull. Will there be an update?
thanks
Any chance for an update ? :)
I spent a short amount of time attempting to fix this, but the solution seems to be much more complex than before. It isn't as simple as crafting a regular html link anymore.
Based on some of the html tag attribute names, the Kijiji site appears to use AngularJS (this isn't a new change), which I am not that familiar with. Something on the back-end must tell the AngularJS front-end when to show a real "repost ad" link, otherwise it is normally hidden. I don't know if it would be possible to fake this behaviour, or if it's something that gets checked and verified by the back-end before the site would allow a free ad repost.
thanks for you answer, if this is too complicated, maybe try to include the repost of the picture in the other script for easy ad re-posting ?
thanks
any chance for update? Here is a chrome extention that seems to be doing the same thing as this script, but with a little more stolen code from others. He charges 30$ for this, what a rip
If you are comfortable with running a Python script (Python is available on both Linux and windows), then I would suggest using the Kijiji-Repost-Headless project.
This is what I use now to repost my Kijiji ads, and it is being actively developed. Unfortunately it is not quite as simple to use as clicking a button in your browser, but it does work. Perhaps someday it could be developed into a real browser extension to make it easier to use.
This works great, thanks for making this!