-
-
Save jasonkeene/c366221284d2ee8a6e0e to your computer and use it in GitHub Desktop.
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 Hipchat Click to View Images | |
// @version 0.2 | |
// @match https://*.hipchat.com/chat | |
// @copyright 2014, Zach "theY4Kman" Kanzler | |
// @grant GM_unsafeWindow | |
// ==/UserScript== | |
// Add styles to initially disable images | |
unsafeWindow.$('head').append([ | |
'<style type="text/css">', | |
'.preview .image a {', | |
' display: none;', | |
'}', | |
'.preview .image:before,', | |
'.preview .image:after {', | |
' font-style: italic;', | |
' color: grey;', | |
' cursor: pointer;', | |
'}', | |
'.preview .image:before {', | |
' content: "Click to show.";', | |
'}', | |
'.preview .image:after {', | |
' content: "";', | |
'}', | |
'.preview.shown .image a {', | |
' display: block;', | |
'}', | |
'.preview.shown .image:before {', | |
' content: "";', | |
'}', | |
'.preview.shown .image:after {', | |
' content: "Click to hide.";', | |
'}', | |
'</style>' | |
].join('\n')); | |
// add global event handler that toggles class of image preview | |
unsafeWindow.$(document).on('click', '.preview .image', function () { | |
$(this).parent().toggleClass('shown'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment