【油猴】Linux.do按帖子创建时间排序【已更新,见28楼】

话不多说,直接上图片和油猴代码:

代码更新在28楼:

代码复制,如有更好的实现方式欢迎佬友们提出:

// ==UserScript==
// @name         Linux.do按帖子创建时间排序
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  在 Linux.do 网页上修改链接和增加新链接
// @author       马克思
// @match        https://linux.do/*
// @match        https://linux.do/latest
// @match        https://linux.do/latest?order=created
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linux.do
// ==/UserScript==

(function() {
    'use strict';

    function modifyAndAddButtons() {
        const latestButton = document.querySelector('a[href="/latest"][class="active"][aria-current="true"]');
        if (latestButton && !latestButton.getAttribute('data-modified')) {
            latestButton.textContent = '最新回复';
            latestButton.setAttribute('data-modified', 'true');

            const newlyCreatedButton = latestButton.cloneNode(true);
            newlyCreatedButton.textContent = '最新创建';
            newlyCreatedButton.href = '/latest?order=created';
            newlyCreatedButton.removeAttribute('aria-current');
            newlyCreatedButton.style.marginLeft = '10px';
            newlyCreatedButton.setAttribute('data-modified', 'true');

            latestButton.parentNode.insertBefore(newlyCreatedButton, latestButton.nextSibling);
        }
    }

    const observer = new MutationObserver(function(mutationsList, observer) {
        for(let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                modifyAndAddButtons();
            }
        }
    });

    const config = { childList: true, subtree: true };
    const targetNode = document.body;
    observer.observe(targetNode, config);
    modifyAndAddButtons();
})();
26 个赞

搞七捻三软件开发

1 个赞

油猴在佬们手中真的跟核武器一样。

7 个赞

都是佬,菜坤的我表示膜拜 :melting_face:

2 个赞

其实没有必要啊,只需要存书签就行了。
LINUX DO 存为书签,需要的时候点一下就行了。

3 个赞

油猴无所不能~

2 个赞

:face_with_peeking_eye:话说,你不引用一下我的原贴,合适吗?

2 个赞

估计还有在憋大招的

2 个赞

来自这位佬友的思路

2 个赞

可以加一个 未读的新话题 按照创建时间排序一下 https://linux.do/new?order=created

2 个赞

迟早被插件攻破

2 个赞

马克思,始皇帝说你再这样送你去见马克思,你信不信?

3 个赞

可不可以倒序排列,这样就能刷以前没看过的贴子,刷看贴量了

2 个赞

安装上了,贼好用

2 个赞

舒服了,终于有按创建时间排序

1 个赞

油猴无所不能

1 个赞

厉害了

1 个赞

棒!佬是否可以授权代码,加入我的linuxdo-next脚本!

1 个赞

卧槽,大佬牛逼,舒服了

1 个赞

拿去用就好不用署名

1 个赞