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

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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
  }
})()