andriod studio官网:如何用GreaseMonkey扩展美化阅读器

来源:百度文库 编辑:偶看新闻 时间:2024/05/06 17:29:14

如何用GreaseMonkey扩展美化阅读器


  请注意,本章节是留给那些富有 DIY 精神,并且略懂网页基础知识的网友。假如你对上述这些界面优化脚本都不满意,想自己动手写一个脚本来美化阅读器。那么,本章节对你应该有帮助。
  反之,如果你对技术一窍不通,或者怕麻烦、或者没时间,请略过本章节。

◇如何美化?


  上述这些脚本对 Google Reader 的界面调整,说白了都是修改CSS(层叠样式表)。在油猴脚本中,可以调用 GM_addStyle 函数,往当前页面加入一个新的样式表。如果你略懂 CSS,搞清楚这些脚本的代码应该对你来说就易如反掌。

◇调整正文宽度


  以下代码用于修改正文的显示宽度,让正文的宽度能充满屏幕。

GM_addStyle(".entry .entry-body, .entry .entry-title { max-width:100% !important; }");


◇压缩搜索条高度


  以下代码调整阅读器搜索条的高度(也就是阅读器上方有:Logo、搜索框、搜索按钮的那一行)。代码中的 40px 和 6px 表示高度(像素为单位),你可以根据自己喜好,微调这2个数字。

GM_addStyle("#top-bar { height:40px !important; }");
GM_addStyle("#search { padding:6px 0px !important; }");


◇压缩工具条高度


  以下代码调整工具条的高度(也就是阅读器上方有:"订阅"、"标为已读"、"供稿设置"等按钮的那一行)。

GM_addStyle("#viewer-header { height:40px !important; }");
GM_addStyle("#lhn-add-subscription-section { height:40px !important; }");
GM_addStyle("#lhn-add-subscription, #viewer-top-controls-container { margin-top:-15px !important; }");


◇压缩文章列表的行高


  新版界面的文章列表,行高大得离谱了,必须得调小。如下代码可以搞定。

GM_addStyle("#entries { padding:0px !important; }");
// 1.2em 表示行高是字体高度的1.2倍。
GM_addStyle(".collapsed { line-height:1.2em !important; padding:2px 0 !important; }");
// 设置列表左边星号的位置
GM_addStyle(".entry-icons { top:12px !important }");
// 设置列表里文字标题的位置
GM_addStyle(".entry-source-title { top:2px !important }");
GM_addStyle(".entry-secondary { top:2px !important }");
// 设置列表右边"打开原始URL"图标的位置
GM_addStyle(".entry-main .entry-original { top:12px !important }");


◇压缩导航树的左边距


  导航树左边留了一大块空白,也不知要作甚?用如下代码压缩掉。

GM_addStyle(".section-minimize { left:0px !important }");
GM_addStyle("#overview-selector, #lhn-selectors .selector, .folder .name.name-d-0, #sub-tree-header { padding-left:15px !important; }");
GM_addStyle(".folder .folder .folder-toggle { margin-left:12px !important }");
GM_addStyle(".folder .sub-icon, .folder .folder>a>.icon { margin-left:27px !important }");
GM_addStyle(".folder .folder>ul .icon { margin-left:34px !important }");
GM_addStyle(".folder .folder .name-text { max-width:160px; !important }");
GM_addStyle("#reading-list-selector .label { display:inline !important }");


◇压缩导航树不同部分之间的间隙


  导航树由4部分组成,分别是:"主页"(Home)、"所有条目"(All items)、"探索"(Explore)、"订阅"(Subscriptions)。这4块之间的间隙太大,用如下代码压缩。

GM_addStyle(".selectors-footer { margin-bottom:0px !important; padding-bottom:0px !important; }");
GM_addStyle(".lhn-section-footer { margin-bottom:0px !important; padding-bottom:0px !important; }");


◇隐藏导航树的某些部分


  导航树的这4部分,通常是"订阅"用得最多。其它3部分如果用得少,嫌它们太占空间,可以用如下代码隐掉。

// 隐藏"主页"
GM_addStyle("#overview-selector { display:none !important; }");
// 隐藏"所有条目"
GM_addStyle("#lhn-selectors { display:none !important; }");
// 隐藏"探索"
GM_addStyle("#lhn-recommendations { display:none !important; }");


◇调整导航树的宽度


  由于不同人的偏好及屏幕尺寸各有差异。因此,很多刁钻滴用户(比如俺)对导航树占的宽度不满意。你可以用如下代码来调整。代码中的 240px 表示宽度,你可以根据喜好来调整。在这3行代码中,此数值要保持一致。

GM_addStyle("#nav, #nav * { max-width:240px !important; }");
GM_addStyle("#nav { width:240px !important; }");
GM_addStyle("#chrome { margin-left:240px !important; }");


★结尾


  今天说了这一大坨,也不知道大伙儿是否有兴趣?如果大伙儿对油猴的兴趣比较大,俺可以找时间再介绍其它一些实用的油猴脚本。