Last active
July 31, 2017 03:27
-
-
Save jackm/c0e4b3e6b2d3965f21387e00a0068c7b to your computer and use it in GitHub Desktop.
Greasemonkey/Tampermonkey script for simple ad re-posting on Kijiji.ca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cerberii
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.