GDocs - Focus Mode

In Google docs press 'Hide the menus' button, to enter focus mode.

  1. // ==UserScript==
  2. // @name GDocs - Focus Mode
  3. // @namespace qpqp.dk
  4. // @version 0.1
  5. // @description In Google docs press 'Hide the menus' button, to enter focus mode.
  6. // @author Viktor Strate
  7. // @match https://docs.google.com/document/*
  8. // @require https://code.jquery.com/jquery-3.2.1.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var style = '<style id="focusModeStyle">' +
  15. '.kix-paginateddocumentplugin, .kix-page-paginated { box-shadow: none; }'+
  16. '.kix-page:not(:first-child) .kix-page-header { border-top: 1px solid #ddd; }' +
  17. '.kix-appview-editor { background-color: #fff; }' +
  18. '</style>';
  19.  
  20. var toolbar = $("#docs-toolbar-wrapper");
  21. toolbar.css("background-image", "none");
  22. toolbar.css("background-color", "#eee");
  23.  
  24. $("#viewModeButton").mouseup(function(){
  25. // Let google update the DOM first
  26. setTimeout(updateFocusMode, 0);
  27. });
  28.  
  29. function updateFocusMode() {
  30. // Is show menus button pressed or not
  31. var checked = $("#viewModeButton .docs-icon-img-container").hasClass("docs-icon-exit-compact");
  32. setFocusMode(checked);
  33. }
  34.  
  35. function setFocusMode(focus) {
  36. console.log("Setting focus mode: "+focus);
  37. var focusStyle = $("#focusModeStyle");
  38. var explorer = $(".docs-explore-widget").first();
  39.  
  40. if (focus) {
  41. if(focusStyle.length===0)
  42. $("body").append(style);
  43. explorer.hide();
  44. } else {
  45. if(focusStyle.length>0)
  46. focusStyle.remove();
  47. explorer.show();
  48. }
  49. }
  50.  
  51. // Initial update
  52. updateFocusMode();
  53. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址