Last active
May 26, 2016 11:24
-
-
Save r-k-b/1a4bd40a8acd8eef13d4be2553a7c77c to your computer and use it in GitHub Desktop.
Expose links to the individual Media Download items in the Business Catalyst admin panel.
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 Expose links to individual Media Download items in BC | |
// @namespace https://gist.github.com/r-k-b/ | |
// @version 1.0.0 | |
// @description Expose links to the individual Media Download items in the Business Catalyst admin panel. | |
// @author Robert K. Bell | |
// @homepage https://bitbucket.org/snippets/bigbluedigital/zLzer | |
// @downloadURL https://gist.github.com/r-k-b/1a4bd40a8acd8eef13d4be2553a7c77c/raw/expose-mediadownload-ids.user.js | |
// @include *://*/* | |
// @grant none | |
// @run-at context-menu | |
// ==/UserScript== | |
/* jshint esnext: true */ | |
(function() { | |
/* Expose links to the individual Media Download items in the Business Catalyst admin panel. | |
* | |
* Intended to be run from the Dev Tools snippet panel. | |
* | |
* Homepage: https://bitbucket.org/snippets/bigbluedigital/zLzer | |
*/ | |
var $ = jQuery, | |
mdLinks = $('a[href*="/_literature_"], a[href*="/LiteratureRetrieve"]'), | |
linkRegexA = /_literature_(\d+)/, | |
linkRegexB = /LiteratureRetrieve\.aspx\?ID\=(\d+)/; | |
var getId = elem => { | |
var href = $(elem).attr('href'); | |
return linkRegexA.test(href) ? linkRegexA.exec(href)[1] : linkRegexB.exec(href)[1]; | |
} | |
var showId = (elem, id) => | |
$(elem).before(` | |
<a target="blank" | |
href="/Admin/Literature_Details.aspx?LiteratureID=${id}"> | |
${id} | |
</a> ` | |
) | |
$(mdLinks).each((index, link) => { | |
showId(link, getId(link)); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment