Greasy Fork镜像 is available in English.

Fix Order of GitHub Dashboard

Orders entries on the GitHub dashboard page from the newest one to the oldest one on the page load.

Ekde 2024/12/07. Vidu La ĝisdata versio.

// ==UserScript==
// @name         Fix Order of GitHub Dashboard
// @namespace    http://prantlf.me/
// @version      1.1
// @description  Orders entries on the GitHub dashboard page from the newest one to the oldest one on the page load.
// @author       [email protected]
// @license      MIT
// @match        https://github.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  let retries = 10
  const interval = setInterval(reorder, 500)
  function reorder() {
    const feed = document.getElementById('conduit-feed-frame')
    if (!feed) {
      console.log('no articles found')
      if (!--retries) {
        clearInterval(interval)
      }
      return
    }
    clearInterval(interval)
    const articles = Array
      .from(feed.children)
      .filter(({ tagName }) => tagName === 'ARTICLE')
    for (const article of articles) {
      const div = article.nextElementSibling
      article.div = div
      const time = article.querySelector('relative-time')
      article.time = time && new Date(time.getAttribute('datetime')) || new Date
      article.remove()
      div.remove()
    }
    articles.sort((l, r) => l.time < r.time ? 1 : l.time > r.time ? -1 : 0)
    let current = feed.firstElementChild
    for (const article of articles) {
      const { div } = article
      current.insertAdjacentElement('afterend', article)
      article.insertAdjacentElement('afterend', div)
      delete article.div
      delete article.time
      current = div
    }
    console.log(articles.length, 'articles reordered')
  }
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。