Greasy Fork

来自缓存

Greasy Fork is available in English.

COCO漫画收藏按更新时间排序

COCO 漫画“我的收藏”界面根据“更新日”进行排序

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        COCO漫画收藏按更新时间排序
// @namespace   https://gitee.com/Kaiter-Plus/TampermonkeyScript/tree/master/COCO漫画收藏按更新时间排序
// @match       *://*.cocomanhua.com/dynamic/user/subscription
// @match       *://*.cocomanga.com/dynamic/user/subscription
// @match       *://*.colamanhua.com/dynamic/user/subscription
// @match       *://*.colamanga.com/dynamic/user/subscription
// @version     0.80
// @author      Kaiter-Plus
// @icon        https://www.colamanga.com/favicon.ico
// @description COCO 漫画“我的收藏”界面根据“更新日”进行排序
// @grant       GM_addStyle
// ==/UserScript==
;(function () {
  'use strict'
  const container = document.getElementsByClassName('fed-user-list fed-part-rows fed-back-whits')[0]
  const all = document.getElementsByClassName('fed-padding-x fed-part-rows fed-line-top')
  // 实现排序
  container.innerHTML =
    document.getElementsByClassName('fed-padding-x fed-part-rows')[0].outerHTML +
    Array.from(all)
      .sort((a, b) => getDateTime(b) - getDateTime(a))
      .map(item => item.outerHTML)
      .join('')

  // 添加最新更新样式
  GM_addStyle(`
    .lastUpdate a {
      color: red;
    }
    .lastUpdate a:visited {
      color: #000;
    }
    .lastUpdate a:hover {
      color: #27ae60;
    }
  `)

  // 获取更新时间戳
  function getDateTime(DOM) {
    const updateTime = new Date(DOM.children[0].children[3].innerHTML).getTime()
    if (new Date(updateTime).toLocaleDateString() === new Date().toLocaleDateString()) {
      DOM.classList.add('lastUpdate')
    }
    return updateTime
  }
})()