tampermonkey 實用腳本

@2018/11/29

使用背景

自從開始使用高分屏的 thinkpad,我總覺得那些經常光顧的網站字體太小,看起來既費勁又容易睡覺,因此就想着把它們調大一點。

爲了從系統層面解決這一問題,我加大了系統的整體字號:

  • 拒絕使用百分比縮放圖標尺寸
    那樣無論使用什麼字體、怎麼調整,都會模糊
  • 使用僅更改字體大小
    將下拉列表項的字體全部設置爲 10 號(默認9號)。
    image

做了以上設置,打開資源管理器以及安裝的軟件,字體都要大一些,看起來能夠適應了。但是瀏覽器打開的網站,他們都有各自的字號,還是有些偏小。尤其是 github。所以我還得折騰一下瀏覽器。

一般情況下,調整瀏覽器默認字體大小,我們可以在設置裏面修改字體,或者按住Ctrl+鼠標滾輪臨時放大瀏覽器頁面就可以了。但是也有一些問題:

  • 設置修改的是全局字體,字體過大,一些網站的導航欄會顯示異常,比如字體顯示一半或者不能正常顯示
  • 放大頁面,頁面佈局會發生變化,有時候甚至扭曲變形

所以後來我就想到了用 F12 直接來修改字號,但是每次都這麼改必然很蛋疼,有沒有腳本啥的?有!

Tampermonkey 就是專門做這個事情的。

Tampermonkey 是一款免費的瀏覽器擴展和最爲流行的用戶腳本管理器,它適用於 Chrome, Microsoft Edge, Safari, Opera Next, 和 Firefox。

Greasy Fork 是一個免費的腳本商城,它的腳本可以直接在 Tampermonkey 中安裝和使用。

下面就是我常用的一些腳本,包括別人提交到 Greasy Fork 的在線腳本,以及我自己臨摹的的一些 js 代碼(只能在本地添加使用)。

這些腳本的大部分目的都是爲了修改頁面寬度字體大小,以及屏蔽一些廣告

我不懂 JavaScript,其中的自有腳本是使用過程中用 F12 一步一步積累出來的,肯定寫得不好,歡迎指正。

有行家能幫我合併這些分散的腳本到一個腳本了麼?求指點。

現成腳本

GitHub file list beautifier

繞過搜索結果網頁鏈接重定向

Bypass Google Sorry (reCAPTCHA)

EX-百度雲盤

Direct download from Google Play

自有腳本

修改有道雲筆記分享頁面寬度

爲了方便在其它地方安裝,這個腳本我提交到了 Greasy Fork。
地址:修改有道雲筆記分享頁面寬度

// ==UserScript==
// @name         修改有道雲筆記分享頁面寬度
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  修改有道雲筆記分享頁面寬度,以便更加適合閱讀。
// @author       High Jiang
// @match        *://note.youdao.com/share/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.file{ min-width: 256px; max-width: 1080px; width: 100%; padding-left: 0px; padding-right: 0px;} .file-name-container{ padding-left: 5%;}';
    document.head.appendChild(style);

})();

Better github read

爲了方便在其它地方安裝,這個腳本我提交到了 Greasy Fork。
地址:Better github read

// ==UserScript==
// @name         Better github read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整Github頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        https://github.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.markdown-body{ font-size: 1.4em } .repository-content{ min-width: 256px; max-width: 1080px; width: 100% } .discussion-timeline{ min-width: 256px; max-width: 1080px; width: 100%; } .container{max-width: 1080px; width: 100%;}';
    document.head.appendChild(style);
    //.timeline-new-comment{max-width: 1080px; width: 100%;}

    var items = document.querySelectorAll('#wiki-content, #discussion_bucket');
    for (var i = 0; i < items.length; i++) {
      items[i].style.width = "1320px";
    }
})();

Better CSDN read

// ==UserScript==
// @name         Better CSDN read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://blog.csdn.net/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.recommend-right{ visibility: hidden; } .fourth_column{ visibility: hidden; } .recommend-box{ visibility: hidden; }'
    document.head.appendChild(style);

    document.getElementById("asideFooter").remove();
    document.getElementById("dmp_ad_58").remove();

})();

Better gopl read

// ==UserScript==
// @name         Better gopl read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整 Gopl 頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        *://b.ykfq.me/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.page-inner{ max-width: 1080px; width: 100%; font-size: 16px}';
    document.head.appendChild(style);

})();

Better zhihu Read

// ==UserScript==
// @name         Better zhihu Read
// @namespace    https://www.zhihu.com
// @version      0.1
// @description  去掉知乎問題頁側邊欄並進行界面居中優化
// @author       High Jiang
// @match        *://www.zhihu.com/question/*
// @run-at       document-start
// ==/UserScript==
(function() {
    'use strict';
    var style = document.createElement('style');
    style.innerHTML =".Question-mainColumn { max-width: 1080px; width: 100%; padding-bottom: 20px;} .Question-sideColumn{width: 0}"
    document.head.appendChild(style);
})();

Better medium read

// ==UserScript==
// @name         Better medium read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整 Medium 頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        https://medium.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.postArticle--full .sectionLayout--insetColumn{ max-width: 1080px; width: 100%; font-size: 16px}';
    document.head.appendChild(style);

    document.getElementsByClassName("u-marginAuto u-maxWidth1000 js-postLeftSidebar")[0].remove()

})();

Better jobbole read

// ==UserScript==
// @name         Better jobbole read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整 伯樂在線 頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        *://*.jobbole.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.container .grid-8 .container{ max-width: 940px; width: 100% } .grid-8{ max-width: 940px; width: 100% } .grid-4{ max-width: 450px; width: 100% }'
    document.head.appendChild(style);

    //document.getElementsByClassName("u-marginAuto u-maxWidth1000 js-postLeftSidebar")[0].remove()

})();

Better Ceph read

// ==UserScript==
// @name         Better Ceph read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://docs.ceph.com/*
// @match        *://docs.ceph.org.cn/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.document{ font-size: 17px; }'
    document.head.appendChild(style);

    document.getElementById("asideFooter").remove();

})();

Better prometheus read

// ==UserScript==
// @name         Better prometheus read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整Github頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        https://prometheus.io/docs/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.container{max-width: 1320px; width: 100%; } .col-md-9{width: 80%;} .col-md-3{ width: 20%; } .doc-content{ font-size: 18px;} .toc-right{ width: 30%; } '
    document.head.appendChild(style);

})();

Better OpenStack read

// ==UserScript==
// @name         Better OpenStack read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整 OpenStack 文檔中心頁面寬度及字體大小,以更加適合閱讀。
// @author       High Jiang
// @match        https://docs.openstack.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.getElementsByClassName("container docs-book-wrapper")[0].style= "width: 1366px; font-size: 18px"
})();

Better jianshu read

// ==UserScript==
// @name         Better jianshu read
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  調整 伯樂在線 頁面寬度及字體大小,以便更加適合閱讀。
// @author       High Jiang
// @match        https://www.jianshu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = document.createElement('style');
    style.innerHTML = '.note .post{ max-width: 960px; width: 100% }'
    document.head.appendChild(style);

    document.getElementById("web-note-ad-fixed").remove()

})();

Better StackOverflow read

沒搞定,歡迎補充。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章