Quip

Fix formatting and hide the conversation sidebar on Quip pages

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

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