Skip to content

Instantly share code, notes, and snippets.

@jasonkeene
Forked from theY4Kman/click_to_show.tamper.js
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonkeene/c366221284d2ee8a6e0e to your computer and use it in GitHub Desktop.
Save jasonkeene/c366221284d2ee8a6e0e to your computer and use it in GitHub Desktop.
// ==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