Greasy Fork

Greasy Fork is available in English.

修改知乎日报标题

修改知乎日报标题为文章标题

当前为 2020-09-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         修改知乎日报标题
// @namespace    https://tmr.js.org/
// @more         https://github.com/ttttmr/UserJS
// @version      0.4
// @description  修改知乎日报标题为文章标题
// @author       tmr
// @match        *://daily.zhihu.com/story/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    function rename() {
        let zh_title = document.querySelector("p[class=DailyHeader-title]").innerText;
        document.querySelector("title").innerText = zh_title + "-知乎日报";
        document.addEventListener('visibilitychange', () => setTimeout(rename, 500));
    }
    if (document.readyState == 'loading') {
        document.addEventListener('DOMContentLoaded', rename);
    } else {
        rename();
    }
})();