Last active
January 27, 2025 13:04
-
-
Save MaximumFX/659e8ab8803974ace139dc245fa8be40 to your computer and use it in GitHub Desktop.
TamperMonkey ShotGrid Field IDs
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 ShotGrid Field IDs | |
// @namespace https://maximumfx.nl/ | |
// @version v1.0.0 | |
// @description Add ShotGrid field ids to the info overview. | |
// @author MaximumFX | |
// @match https://*.shotgunstudio.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=shotgunstudio.com | |
// @grant none | |
// ==/UserScript== | |
// Convenience function to execute your callback only after an element matching readySelector has been added to the page. | |
// Example: runWhenReady('.search-result', augmentSearchResults); | |
// Gives up after 1 minute. | |
function runWhenReady(readySelector, callback) { | |
var numAttempts = 0; | |
var tryNow = function() { | |
var elem = document.querySelector(readySelector); | |
if (elem) { | |
callback(elem); | |
} else { | |
numAttempts++; | |
if (numAttempts >= 34) { | |
console.warn('Giving up after 34 attempts. Could not find: ' + readySelector); | |
} else { | |
setTimeout(tryNow, 250 * Math.pow(1.1, numAttempts)); | |
} | |
} | |
}; | |
tryNow(); | |
} | |
(function() { | |
'use strict'; | |
runWhenReady(".info_tab_content [sg_id]", () => { | |
[...document.querySelectorAll(".info_tab_content [sg_id]")].forEach(elem => { | |
const text_elem = elem.querySelector("[sg_selector='field:name'] div") | |
text_elem.textContent = text_elem.textContent.trim() + ` (${elem.getAttribute('sg_id').replace('field:', '')})` | |
}) | |
console.info('Added ShotGrid field ids.'); | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the Stylebot extension to add the following CSS for better readability: