Quip

Fix formatting and hide the conversation sidebar on Quip pages

当前为 2016-08-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quip
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Fix formatting and hide the conversation sidebar on Quip pages
  6. // @author Ping
  7. // @match https://*.quip.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // Goal: Focus on the content. Here's what this userscript does to Quip:
  12. // - Makes all formatting simple and uniform (Roboto on all pages)
  13. // - Makes headings easier to see (dark red)
  14. // - Hides the gigantic conversation sidebar when you first load any page
  15. // - Prevents the backtick key from horribly cycling through 9 formats
  16. // - Stops Quip from auto-bolding list items that have subitems
  17. // - Reduces the enormous wasteful margins around the page
  18. // - Shrinks the huge annoying bubble with the formatting buttons
  19. // - Shrinks the huge yellow chat button to a reasonable size
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. var head = document.getElementsByTagName('head')[0];
  25. var style = document.createElement('style');
  26. style.type = 'text/css';
  27. style.innerHTML = `
  28. body,
  29. body div#app article div.content,
  30. body div#app article .section[data-section-type="1"] ul li,
  31. body div#app article .section[data-section-type="1"] ul li:before,
  32. body .document-thread div,
  33. body .document-thread div li {
  34. font-family: Roboto, Arial, "Quip Glyphs";
  35. font-weight: 400;
  36. font-size: 13px;
  37. line-height: 1.45;
  38. }
  39.  
  40. body .document-thread div.header div {
  41. font-size: 11px;
  42. }
  43.  
  44. body div#app article .content br {
  45. padding-top: 0.2em;
  46. display: block;
  47. }
  48.  
  49. body div#app article .section[data-section-style="6"] ul li:before {
  50. font-size: inherit;
  51. }
  52.  
  53. body div#app .document article {
  54. padding: 40px 30px;
  55. }
  56.  
  57. /* HL: Main page heading */
  58. body div#app article .section[data-section-style="1"]>.content,
  59. body .document-thread div h1 {
  60. font-size: 28px;
  61. font-weight: 400;
  62. }
  63.  
  64. /* HM: Section heading */
  65. body div#app article .section[data-section-style="2"],
  66. body .document-thread div h2 {
  67. margin: 24px 0 18px;
  68. }
  69.  
  70. body div#app article .section[data-section-style="2"]>.content,
  71. body .document-thread div h2 {
  72. font-size: 20px;
  73. font-weight: normal;
  74. color: #800;
  75. border-bottom: 1px solid #ccc;
  76. }
  77.  
  78. /* HS: Subsection heading */
  79. body div#app article .section[data-section-style="3"],
  80. body .document-thread div h3 {
  81. margin: 24px 0 12px;
  82. }
  83.  
  84. body div#app article .section[data-section-style="3"]>.content,
  85. body .document-thread div h3 {
  86. color: #800;
  87. font-size: 15px;
  88. font-weight: bold;
  89. text-transform: none;
  90. }
  91.  
  92. /* Code block */
  93. body div#app article .section[data-section-style="4"]>.content,
  94. body div#app article .section[data-section-style="0"]>.content code,
  95. body .document-thread div pre {
  96. font-family: Lucida Sans Typewriter, Monaco, Menlo, Courier, monospace, 'Quip Glyphs';
  97. font-size: 12px;
  98. text-shadow: none;
  99. }
  100.  
  101. body div#app article .section[data-section-style="4"]>.content {
  102. padding: 3px 3px 3px 24px;
  103. }
  104.  
  105. body div#app article .section[data-section-style="0"]>.content code {
  106. display: inline-block;
  107. padding: 1px 2px;
  108. margin: 0 1px;
  109. border-radius: 2px;
  110. }
  111.  
  112. /* Bulleted list section */
  113. body div#app article .section[data-section-style="5"] {
  114. margin: 12px 0 6px;
  115. }
  116.  
  117. /* Numbered list section */
  118. body div#app article .section[data-section-style="6"] {
  119. margin: 12px 0 6px;
  120. }
  121.  
  122. /* Normal text */
  123. body div#app article .section[data-section-style="0"]>.content {
  124. font-size: 13px;
  125. }
  126.  
  127. /* Block quote */
  128. body div#app article .section[data-section-style="16"] {
  129. margin-top: -0.3em;
  130. margin-bottom: 0;
  131. }
  132.  
  133. body div#app article .section[data-section-style="16"]>.content {
  134. padding-left: 8em;
  135. color: #888;
  136. font-size: 12px;
  137. font-weight: 300;
  138. font-style: italic;
  139. }
  140.  
  141. body div#app article .section[data-section-style="16"]>.content:before {
  142. background: none;
  143. }
  144.  
  145. body div#app article .section[data-section-style="16"]>.content u {
  146. text-transform: uppercase;
  147. color: #0a4;
  148. font-size: 12px;
  149. font-style: normal;
  150. font-weight: normal;
  151. text-decoration: none;
  152. margin-left: -2em;
  153. padding-right: 0.7em;
  154. }
  155.  
  156. div#toc-div ul li a, div ul.listtype-comment li span {
  157. font-weight: 300;
  158. line-height: 1.4em;
  159. }
  160.  
  161. span#sharesummary {
  162. background: none !important;
  163. }
  164.  
  165. div.toc-entry span b {
  166. font-weight: normal;
  167. }
  168.  
  169. div.toc-entry {
  170. margin-bottom: 0.5em;
  171. }
  172.  
  173. #padeditor #add-to-collection {
  174. background: none;
  175. border: none;
  176. }
  177.  
  178. span.user-caret {
  179. left: 0px !important;
  180. }
  181.  
  182. span.user-caret-offscreen-top, span.user-caret-offscreen-bottom {
  183. left: 64px !important;
  184. }
  185.  
  186. span.user-caret img {
  187. display: none;
  188. }
  189.  
  190. span.user-caret-initials {
  191. padding: 3px;
  192. }
  193.  
  194. div.editor-stylebar {
  195. opacity: 0.5;
  196. left: -29px;
  197. top: 0px;
  198. width: 16px;
  199. height: 16px;
  200. }
  201.  
  202. div.editor-stylebar div.editor-stylebar-style {
  203. width: 16px;
  204. height: 16px;
  205. background-size: 12px 12px;
  206. }
  207.  
  208. div.editor-stylebar div.editor-stylebar-selection-background {
  209. width: 14px;
  210. height: 14px;
  211. top: 1px;
  212. left: 1px;
  213. }
  214.  
  215. div.editor-stylebar.visible.expanded {
  216. left: 14px;
  217. }
  218.  
  219. .editor-stylebar .editor-stylebar-bubble,
  220. .editor-stylebar.expanded.cover-text .editor-stylebar-bubble {
  221. width: 54px;
  222. height: 64px;
  223. transform: translate3d(-42px, -24px, 0);
  224. }
  225.  
  226. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="0"],
  227. .editor-stylebar.expanded.cover-text[data-section-style="0"] .editor-stylebar-selection-background {
  228. transform: translate3d(-39px, -21px, 0);
  229. }
  230.  
  231. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="1"],
  232. .editor-stylebar.expanded.cover-text[data-section-style="1"] .editor-stylebar-selection-background {
  233. transform: translate3d(-39px, 0, 0);
  234. }
  235.  
  236. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="2"],
  237. .editor-stylebar.expanded.cover-text[data-section-style="2"] .editor-stylebar-selection-background {
  238. transform: translate3d(-23px, 0, 0);
  239. }
  240.  
  241. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="3"],
  242. .editor-stylebar.expanded.cover-text[data-section-style="3"] .editor-stylebar-selection-background {
  243. transform: translate3d(-7px, 0, 0);
  244. }
  245.  
  246. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="4"],
  247. .editor-stylebar.expanded.cover-text[data-section-style="4"] .editor-stylebar-selection-background {
  248. transform: translate3d(-7px, -21px, 0);
  249. }
  250.  
  251. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="5"],
  252. .editor-stylebar.expanded.cover-text[data-section-style="5"] .editor-stylebar-selection-background {
  253. transform: translate3d(-39px, 21px, 0);
  254. }
  255.  
  256. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="6"],
  257. .editor-stylebar.expanded.cover-text[data-section-style="6"] .editor-stylebar-selection-background {
  258. transform: translate3d(-7px, 21px, 0);
  259. }
  260.  
  261. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="7"],
  262. .editor-stylebar.expanded.cover-text[data-section-style="7"] .editor-stylebar-selection-background {
  263. transform: translate3d(-23px, 21px, 0);
  264. }
  265.  
  266. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="16"],
  267. .editor-stylebar.expanded.cover-text[data-section-style="16"] .editor-stylebar-selection-background {
  268. transform: translate3d(-23px, -21px, 0);
  269. }
  270.  
  271. .annotation-gutter-icon {
  272. left: 12px;
  273. margin-top: -1px;
  274. width: 20px;
  275. height: 20px;
  276. background-size: 20px 20px;
  277. }
  278.  
  279. .annotation-gutter-icon.numbered {
  280. font-size: 10px;
  281. line-height: 19px;
  282. }
  283. `;
  284. head.appendChild(style);
  285.  
  286. // Disable the annoying backtick key.
  287. document.body.addEventListener('keydown', function(event) {
  288. if (event.keyCode === 192) {
  289. console.log('blocked keydown event for backtick');
  290. event.stopPropagation();
  291. event.preventDefault();
  292. return false;
  293. }
  294. }, true);
  295.  
  296. // Hide the conversation sidebar.
  297. function hide_conversation() {
  298. var button = document.querySelector('.icon-hide-conversation');
  299. if (button) {
  300. button.click();
  301. } else {
  302. window.setTimeout(hide_conversation, 100);
  303. }
  304. }
  305. hide_conversation();
  306. })();