Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Forked from jasonkeene/click_to_show.tamper.js
Created September 30, 2014 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theY4Kman/ac15459ed66af29a24bf to your computer and use it in GitHub Desktop.
Save theY4Kman/ac15459ed66af29a24bf 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 (evt) {
evt.preventDefault();
$(this).parent().toggleClass('shown');
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment