Skip to content

Instantly share code, notes, and snippets.

@jackm
Last active January 22, 2018 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackm/089416ebccb422b4a3d5 to your computer and use it in GitHub Desktop.
Save jackm/089416ebccb422b4a3d5 to your computer and use it in GitHub Desktop.
Greasemonkey/Tampermonkey script to show hidden cateogry IDs on Kijiji.ca
// ==UserScript==
// @name Kijiji show category ID
// @namespace KijijiScripts
// @version 0.5
// @description Add an indicator to show decoded location IDs and category IDs in the breadcrumb nav list (not normally visible)
// @match https://www.kijiji.ca/*
// @grant none
// ==/UserScript==
(function() {
if (document.querySelector('div[class^="breadcrumbs-"]')) {
var breadcrumUrls = document.querySelectorAll('a[class^="crumbLink-"]');
for (var i = 0; i < breadcrumUrls.length; i++) {
var s = document.createElement("strong");
// Extract out the 'ID' section from the url which is the part after the right most slash
var id = breadcrumUrls[i].href.split('/')[breadcrumUrls[i].href.split('/').length - 1];
// Check if ID string contains an 'l' char or not
// if it does it must be a category ID and if not it must be a location ID
if (id.indexOf('l') >= 0) {
// eg. id could be 'c128l1700212' where the integer between the 'c' and 'l' chars is the category ID
s.innerHTML = " (CatId " + id.split('c').pop().split('l').shift() + ")";
} else {
s.innerHTML = " (LocId " + id + ")";
}
breadcrumUrls[i].parentNode.appendChild(s);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment