Quip

Fix formatting and hide the conversation sidebar on Quip pages

当前为 2017-02-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quip
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  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 div#app .navigation-controller .nav-path input.nav-path-title,
  33. body div#app .document-thread div,
  34. body div#app .document-thread div li,
  35. body div#app .jetson-chat-thread .jetson-message-document-body div,
  36. body div#app .jetson-chat-thread .jetson-message-document-body div li,
  37. body div#app .jetson-chat-thread .jetson-message-document-body div p,
  38. body div#app .search-input input,
  39. .jetson-chat-thread-input .text-box,
  40. .jetson-button-text {
  41. font-family: Roboto, Arial, "Quip Glyphs";
  42. font-weight: 400;
  43. font-size: 13px;
  44. line-height: 1.45;
  45. }
  46.  
  47. /* === toolbar area === */
  48.  
  49. /* folder path */
  50. #app .navigation-controller .nav-path input.nav-path-title {
  51. text-align: left;
  52. }
  53. #app .navigation-controller-path {
  54. justify-content: flex-start;
  55. padding: 0 18px;
  56. height: 18px !important;
  57. }
  58.  
  59. /* "External" warning */
  60. #app .navigation-controller-path .jetson-button {
  61. height: 16px !important;
  62. padding: 0 4px !important;
  63. }
  64.  
  65. /* toolbar buttons */
  66. .jetson-button, #app .nav-global-search {
  67. height: 22px !important;
  68. padding: 0 4px !important;
  69. }
  70. .jetson-button-icon {
  71. height: 16px !important;
  72. }
  73. .jetson-button-text {
  74. font-size: 13px !important;
  75. }
  76. #app .navigation-controller-toolbar .parts-profile-picture img {
  77. width: 22px !important;
  78. height: 22px !important;
  79. margin-top: 3px;
  80. }
  81.  
  82. /* toolbar button area */
  83. #app .navigation-controller-toolbar .navigation-controller-path + div {
  84. opacity: 0.3;
  85. }
  86. #app .navigation-controller-toolbar:hover .navigation-controller-path + div {
  87. opacity: 1;
  88. }
  89. #app .navigation-controller-toolbar {
  90. height: 40px !important;
  91. }
  92.  
  93. /* horizontal rule along the bottom of the toolbar */
  94. .navigation-controller-toolbar:not(.has-notification-bar):after {
  95. background: transparent;
  96. }
  97.  
  98. /* document area, below the toolbar */
  99. #app .navigation-controller-body {
  100. top: 40px !important;
  101. }
  102.  
  103. .parts-toolbar {
  104. padding: 0 18px !important;
  105. }
  106.  
  107. #app .navigation-controller-path + div {
  108. top: 16px !important;
  109. }
  110.  
  111. /* === conversation/history area === */
  112.  
  113. body .jetson-document-chat .parts-screen-body {
  114. box-shadow: inset 0 1px 2px 0px rgba(0,0,0,0.2);
  115. bottom: 32px !important;
  116. }
  117.  
  118. body .jetson-message-document-body div ul {
  119. padding-left: 12px;
  120. }
  121.  
  122. body .document-thread div.header div {
  123. font-size: 11px;
  124. }
  125. body .message-list .jetson-message:not(:first-of-type) {
  126. padding-top: 16px;
  127. }
  128. body .message-list .jetson-message {
  129. padding-left: 8px;
  130. }
  131.  
  132. /* profile icons */
  133. .jetson-message-picture {
  134. width: 22px;
  135. margin-right: 4px;
  136. }
  137. .jetson-message-picture > div > div {
  138. border-radius: 11px !important;
  139. }
  140. .jetson-message-picture > div,
  141. .jetson-message-picture img {
  142. width: 22px !important;
  143. height: 22px !important;
  144. }
  145.  
  146. /* history snippets */
  147. .jetson-message-quote {
  148. margin-top: 0;
  149. padding-left: 8px;
  150. padding-top: 0;
  151. padding-bottom: 0;
  152. }
  153. .jetson-message-quote-links {
  154. margin-top: 6px;
  155. }
  156. .jetson-message-button {
  157. padding-top: 2px;
  158. width: 12px;
  159. height: 12px;
  160. }
  161.  
  162. /* popup chat window */
  163. .parts-panel .navigation-controller-toolbar {
  164. height: 32px !important;
  165. }
  166.  
  167. .parts-panel .parts-toolbar {
  168. padding: 0 8px !important;
  169. }
  170.  
  171. .parts-panel .navigation-controller-body {
  172. margin-top: 32px !important;
  173. }
  174. .parts-panel .jetson-chat-thread .parts-screen-body {
  175. margin-bottom: 32px !important;
  176. }
  177.  
  178.  
  179. /* chat box */
  180. .jetson-chat-thread-input .input .text-box {
  181. font-size: 13px;
  182. line-height: 1.45;
  183. padding: 2px 6px;
  184. }
  185.  
  186. .message-input-jetson-attach, .message-input-jetson-emoji {
  187. width: 12px;
  188. height: 12px;
  189. margin-right: 2px;
  190. margin-top: 4px;
  191. }
  192.  
  193. .parts-screen-footer {
  194. height: 32px !important;
  195. }
  196.  
  197. .jetson-chat-thread-footer {
  198. padding-left: 12px !important;
  199. padding-right: 12px !important;
  200. }
  201.  
  202. /* === overall margins === */
  203.  
  204. .parts-screen-body, .parts-screen-children-wrapper {
  205. padding: 0 !important;
  206. }
  207. body div#app .document article.article {
  208. padding: 0 18px 18px;
  209. }
  210.  
  211. body div#app article .content br {
  212. padding-top: 0.2em;
  213. display: block;
  214. }
  215.  
  216. body div#app article .section[data-section-style="6"] ul li:before {
  217. font-size: inherit;
  218. }
  219.  
  220. body div#app .document article {
  221. padding: 40px 30px;
  222. }
  223.  
  224.  
  225. /* links */
  226. .document a, .link, lnk, .document .article control a.content {
  227. color: #08c;
  228. }
  229.  
  230. /* HL: Main page heading */
  231. body div#app article .section[data-section-style="1"],
  232. body .document-thread div h1 {
  233. margin: 0 0 16px;
  234. }
  235.  
  236. body div#app article .section[data-section-style="1"]>.content,
  237. body .document-thread div h1 {
  238. font-size: 28px;
  239. font-weight: 400;
  240. }
  241.  
  242. /* HM: Section heading */
  243. body div#app article .section[data-section-style="2"],
  244. body .document-thread div h2 {
  245. margin: 20px 0 16px;
  246. }
  247.  
  248. body div#app article .section[data-section-style="2"]>.content,
  249. body .document-thread div h2 {
  250. font-size: 20px;
  251. font-weight: normal;
  252. color: #800;
  253. border-bottom: 1px solid #ccc;
  254. }
  255.  
  256. /* HS: Subsection heading */
  257. body div#app article .section[data-section-style="3"],
  258. body .document-thread div h3 {
  259. margin: 24px 0 12px;
  260. }
  261.  
  262. body div#app article .section[data-section-style="3"]>.content,
  263. body .document-thread div h3 {
  264. color: #800;
  265. font-size: 15px;
  266. font-weight: bold;
  267. text-transform: none;
  268. }
  269.  
  270. /* Code block */
  271. div.document code, div.document pre, div.thread-thumbnail-document code,
  272. body div#app article .section[data-section-style="4"]>.content,
  273. body div#app article .section[data-section-style="0"]>.content code,
  274. body .document-thread div pre {
  275. font-family: "Lucida Sans Typewriter", Monaco, Menlo, Courier, monospace, "Quip Glyphs";
  276. font-size: 12px;
  277. text-shadow: none;
  278. color: #070;
  279. }
  280.  
  281. body div#app article .section[data-section-style="4"]>.content {
  282. padding: 3px 3px 3px 24px;
  283. }
  284.  
  285. body div#app article .section[data-section-style="0"]>.content code {
  286. display: inline-block;
  287. padding: 1px 2px;
  288. margin: 0 1px;
  289. border-radius: 2px;
  290. }
  291.  
  292. /* Bulleted list section */
  293. body div#app article .section[data-section-style="5"] {
  294. margin: 12px 0 6px;
  295. }
  296.  
  297. /* Numbered list section */
  298. body div#app article .section[data-section-style="6"] {
  299. margin: 12px 0 6px;
  300. }
  301.  
  302. /* Normal text */
  303. body div#app article .section[data-section-style="0"]>.content {
  304. font-size: 13px;
  305. }
  306.  
  307. /* Block quote */
  308. body div#app article .section[data-section-style="16"] {
  309. margin-top: -0.3em;
  310. margin-bottom: 0;
  311. }
  312.  
  313. body div#app article .section[data-section-style="16"]>.content {
  314. padding-left: 8em;
  315. color: #888;
  316. font-size: 12px;
  317. font-weight: 300;
  318. font-style: italic;
  319. }
  320.  
  321. body div#app article .section[data-section-style="16"]>.content:before {
  322. background: none;
  323. }
  324.  
  325. body div#app article .section[data-section-style="16"]>.content u {
  326. text-transform: uppercase;
  327. color: #0a4;
  328. font-size: 12px;
  329. font-style: normal;
  330. font-weight: normal;
  331. text-decoration: none;
  332. margin-left: -2em;
  333. padding-right: 0.7em;
  334. }
  335.  
  336. div#toc-div ul li a, div ul.listtype-comment li span {
  337. font-weight: 300;
  338. line-height: 1.4em;
  339. }
  340.  
  341. span#sharesummary {
  342. background: none !important;
  343. }
  344.  
  345. div.toc-entry span b {
  346. font-weight: normal;
  347. }
  348.  
  349. div.toc-entry {
  350. margin-bottom: 0.5em;
  351. }
  352.  
  353. #padeditor #add-to-collection {
  354. background: none;
  355. border: none;
  356. }
  357.  
  358. span.user-caret {
  359. left: 0px !important;
  360. }
  361.  
  362. span.user-caret-offscreen-top, span.user-caret-offscreen-bottom {
  363. left: 64px !important;
  364. }
  365.  
  366. span.user-caret img {
  367. display: none;
  368. }
  369.  
  370. span.user-caret-initials {
  371. padding: 3px;
  372. }
  373.  
  374. div.editor-stylebar {
  375. opacity: 0.5;
  376. left: -48px;
  377. top: 0px;
  378. width: 16px;
  379. height: 16px;
  380. }
  381.  
  382. div.editor-stylebar div.editor-stylebar-style {
  383. width: 16px;
  384. height: 16px;
  385. background-size: 12px 12px;
  386. }
  387.  
  388. div.editor-stylebar div.editor-stylebar-selection-background {
  389. width: 14px;
  390. height: 14px;
  391. top: 1px;
  392. left: 1px;
  393. }
  394.  
  395. div.editor-stylebar.visible.expanded {
  396. left: 14px;
  397. }
  398.  
  399. .editor-stylebar .editor-stylebar-bubble,
  400. .editor-stylebar.expanded.cover-text .editor-stylebar-bubble {
  401. width: 54px;
  402. height: 64px;
  403. transform: translate3d(-42px, -24px, 0);
  404. }
  405.  
  406. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="0"],
  407. .editor-stylebar.expanded.cover-text[data-section-style="0"] .editor-stylebar-selection-background {
  408. transform: translate3d(-39px, -21px, 0);
  409. }
  410.  
  411. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="1"],
  412. .editor-stylebar.expanded.cover-text[data-section-style="1"] .editor-stylebar-selection-background {
  413. transform: translate3d(-39px, 0, 0);
  414. }
  415.  
  416. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="2"],
  417. .editor-stylebar.expanded.cover-text[data-section-style="2"] .editor-stylebar-selection-background {
  418. transform: translate3d(-23px, 0, 0);
  419. }
  420.  
  421. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="3"],
  422. .editor-stylebar.expanded.cover-text[data-section-style="3"] .editor-stylebar-selection-background {
  423. transform: translate3d(-7px, 0, 0);
  424. }
  425.  
  426. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="4"],
  427. .editor-stylebar.expanded.cover-text[data-section-style="4"] .editor-stylebar-selection-background {
  428. transform: translate3d(-7px, -21px, 0);
  429. }
  430.  
  431. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="5"],
  432. .editor-stylebar.expanded.cover-text[data-section-style="5"] .editor-stylebar-selection-background {
  433. transform: translate3d(-39px, 21px, 0);
  434. }
  435.  
  436. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="6"],
  437. .editor-stylebar.expanded.cover-text[data-section-style="6"] .editor-stylebar-selection-background {
  438. transform: translate3d(-7px, 21px, 0);
  439. }
  440.  
  441. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="7"],
  442. .editor-stylebar.expanded.cover-text[data-section-style="7"] .editor-stylebar-selection-background {
  443. transform: translate3d(-23px, 21px, 0);
  444. }
  445.  
  446. .editor-stylebar.expanded.cover-text .editor-stylebar-style[data-style="16"],
  447. .editor-stylebar.expanded.cover-text[data-section-style="16"] .editor-stylebar-selection-background {
  448. transform: translate3d(-23px, -21px, 0);
  449. }
  450.  
  451. .annotation-gutter-icon {
  452. left: 0;
  453. margin-top: -1px;
  454. width: 20px;
  455. height: 20px;
  456. background-size: 20px 20px;
  457. }
  458.  
  459. .annotation-gutter-icon.numbered {
  460. font-size: 10px;
  461. line-height: 19px;
  462. }
  463.  
  464. /* Chat bubbles */
  465. .message-bubble .chat-bubble, .message-bubble .chat-card {
  466. font-size: 12px;
  467. font-weight: 400;
  468. line-height: 15px;
  469. }
  470.  
  471. .chat-bubble .chat-bubble-bg {
  472. border-radius: 6px;
  473. }
  474.  
  475. .chat-bubble .chat-bubble-body {
  476. padding: 6px;
  477. }
  478.  
  479. .app .document-thread .outline-inline-container {
  480. padding-right: 0;
  481. }
  482.  
  483. .app .document-thread .outline-inline-container>.editor-outline {
  484. border-radius: 0;
  485. border-right: none;
  486. margin: 60px 0 0 0;
  487. padding: 4px 0;
  488. }
  489.  
  490. .editor-outline .editor-outline-section {
  491. margin: 4px 8px;
  492. }
  493.  
  494. .editor-outline .editor-outline-section[data-section-style="2"],
  495. .editor-outline .editor-outline-section[data-section-style="3"] {
  496. font-weight: normal;
  497. color: #800 !important;
  498. text-transform: none;
  499. }
  500.  
  501. .app .document-thread .outline-inline-container>.editor-outline .editor-outline-title {
  502. display: none;
  503. }
  504. `;
  505. head.appendChild(style);
  506.  
  507. // Disable the annoying backtick key.
  508. document.body.addEventListener('keydown', function(event) {
  509. if (event.keyCode === 192) {
  510. console.log('blocked keydown event for backtick');
  511. event.stopPropagation();
  512. event.preventDefault();
  513. return false;
  514. }
  515. }, true);
  516.  
  517. // Hide the conversation sidebar.
  518. function hide_conversation() {
  519. var button = document.querySelector('.icon-hide-conversation') ||
  520. document.querySelector('.jetson-document-chat-hide');
  521. if (button) {
  522. button.click();
  523. } else {
  524. window.setTimeout(hide_conversation, 100);
  525. }
  526. }
  527. hide_conversation();
  528. })();