Last active
December 20, 2015 13:09
-
-
Save markbao/6136175 to your computer and use it in GitHub Desktop.
Quip Focus: A bookmarklet that lets you hide the discussion pane when viewing a Quip document, so you can focus on your writing.
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
// Quip Focus | |
// by Mark Bao | |
// Unlicensed: <http://unlicense.org/> | |
// Initialize dat CSS. Anyone know of a better way? | |
var qf_css = 'a.quip-focus {width: 32px; height: 32px; position: absolute; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5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-size: 32px; background-size: 32px; bottom: 5px; left: 5px; z-index: 100000; display: block; transition: all 0.5s ease-in-out; -webkit-transition: all 0.5s ease-in-out;} a.quip-focus:before { height: 32px; -webkit-background-size: 32px; background-size: 32px; width: 32px; opacity: 1; background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyM0U3OTdCQ0YzMTkxMUUyOTQ4REY3RDQ0OUQ4RTM2NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyM0U3OTdCREYzMTkxMUUyOTQ4REY3RDQ0OUQ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tYNkDSpOiXi8B7fzByyHQm+/2JGszhz6TgbwDwZc4daRuGHyafJhMbqzv5TRyWgXNKlUuqvqxOBuNA9nszPd27uo48PvhO/RYHGJ6zJnzl7JCIAXrPjRgSGvOIgqQ63mRX4A04UJdUHGkZQGBjJRPj1NqEtM0sW32rNObXnrh87qamiPEWSliqMSUMAskOA18eUw9G7fv+3X/3M7vu+7rOXGyoX9wMMmkAR7DEuWcaS2m29PYfGpNA01SeqnEtld8mIT7GD7nz5lzOm8YZF680WOalU6nhqZNndq7YsmiQw8/OK+bXTnNxn/EWS+ExdQA2WT49DBfGFXLRg3xF0nFRvlcU8fTz3XwiUsOQkF+bZsQ9955ZsMrlrQfXff8mp8FE6O5VXmR1GU2+sRxnoRYLBW2HOYPzon9sEA7LpgfLYAbJnOecaYF8lone86fr/IwuRrnsWPVioPPPPnE1+zKeYU4jiLZMQTTeVW1v8F+gP0FhnAyOeIvjxsNgCz30FWJhF9NCsmbpsGjivXU46t/Wf3Yqm+FGmcVpIiSJljh26FjB6Dwy1U2g1LqO0hb8tSOJOyEsX7ts11LFy3sYpf+YWNgLJIc66aTUm5idRe1mc+Tinh8eOO6tXsfmjdvnwhdA0KzSvYzlpICgHbCwuO2QVLVicHXN234cuaMGTxrOyfU3iol8yUFwPb0FrXDXN2kmss7trz6WXNz82/s0gXiLGwsOfMlBcCWPMsgp97ZfHHH1s276+vr3YRleLyYLyUABgdg1ozWM9vfeO3TZFUVX8nZKzE/blupAOhvm3vvoXfeerOTHZ+QsjVKxnmDEv1ukK/ZqxN5w6Ww2dqtAEBcpMsWCbmc/VYxAVNInN5MzJdSA27arfyjqTIAZQAm9va/AAMAUBLQqpiWoWoAAAAASUVORK5CYII=); content: ""; position: absolute; transition: all 0.3s ease-in-out; -webkit-transition: all 0.3s ease-in-out; } a.quip-focus:hover:before { width: 10px; } a.quip-focus-active:before { width: 10px; } a.quip-focus-active:hover:before { width: 32px; }', | |
qf_head = document.head, | |
qf_style = document.createElement('style'); | |
qf_style.type = 'text/css'; | |
if (qf_style.styleSheet){ | |
qf_style.styleSheet.cssText = qf_css; | |
} else { | |
qf_style.appendChild(document.createTextNode(qf_css)); | |
} | |
// Lock and load. | |
qf_head.appendChild(qf_style); | |
// Let's add that toggle button to the DOM. | |
var qf_document = document.querySelectorAll('.thread-document .document')[0], | |
qf_a = document.createElement('a'); | |
qf_a.className = 'quip-focus'; | |
qf_a.href = 'javascript:qf_toggle();'; | |
qf_document.appendChild(qf_a); | |
var qf_active = false; | |
// Function for toggle | |
function qf_toggle() { | |
var newClassName; | |
var newLeftValue; | |
var newNavDisplay; | |
var qf_a = document.querySelectorAll('.quip-focus')[0]; | |
if (qf_a.className == 'quip-focus') { | |
newClassName = 'quip-focus quip-focus-active'; // Set active state on button | |
newLeftValue = '-1px'; // Slide the document over | |
newNavDisplay = 'none'; // Hide the discussion nav that displays above doc | |
qf_active = true; | |
} else { | |
newClassName = 'quip-focus'; // Remove active state on button | |
newLeftValue = '350px'; // Slide the document back | |
newNavDisplay = 'block'; // Show the discussion nav again | |
qf_active = true; | |
} | |
qf_a.className = newClassName; | |
document.querySelectorAll('.thread-document')[0].style.transition = 'all 0.2s ease-in-out'; | |
document.querySelectorAll('.thread-document')[0].style.webkitTransition = 'all 0.2s ease-in-out'; | |
document.querySelectorAll('.thread-document')[0].style.left = newLeftValue; | |
document.querySelectorAll('nav[data-click=messages]')[0].style.display = newNavDisplay; | |
} | |
window.qf_toggle = qf_toggle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still works—used it in Chrome today.