Last active
May 26, 2016 09:28
-
-
Save r-k-b/1b89a057231055fb0f231b304df8a78e to your computer and use it in GitHub Desktop.
Show List IDs in BC Admin
This file contains 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 Show List IDs in BC Admin | |
// @namespace https://gist.github.com/r-k-b/ | |
// @version 1.0.0 | |
// @description Show the ID of all visible list items. Works on most lists in BC. | |
// @author Robert K. Bell | |
// @homepage https://gist.github.com/r-k-b/1b89a057231055fb0f231b304df8a78e | |
// @downloadURL https://gist.github.com/r-k-b/1b89a057231055fb0f231b304df8a78e/raw/show-list-IDs-in-BC-admin.user.js | |
// @include *://*/* | |
// @grant none | |
// @run-at context-menu | |
// ==/UserScript== | |
/* jshint esnext: true */ | |
(() => { | |
jQuery.each( | |
[ | |
'a.treenode', // Expandable tree views, e.g. Classifications | |
'.item-list > a', // List views, e.g. Pages | |
'.rgMasterTable td > a' // List views, e.g. Page Templates | |
], | |
function (index, elem) { | |
jQuery(elem).each(function (index, element) { | |
try { | |
if (!jQuery(element).data('already-grabbed-the-id')) { | |
jQuery(element).html( | |
'#' + | |
jQuery(element).attr('href').split('=')[1] + | |
' - ' + | |
jQuery(element).html() | |
); | |
jQuery(element).data('already-grabbed-the-id', true); | |
} | |
} catch (TypeError) { | |
// todo: error handling? | |
} | |
}); | |
} | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment