您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Sorts projects from Projects page based on the creation date
// ==UserScript== // @name Glassfrog Projects sort by timestamp // @namespace https://github.com/pusi77 // @match https://app.glassfrog.com/organizations/*/orgnav/roles/*/projects* // @grant none // @version 1.4 // @author pusi77 // @description Sorts projects from Projects page based on the creation date // ==/UserScript== const delay = ms => new Promise(res => setTimeout(res, ms)); function parseDateFromString(dateString) { const parts = dateString.match(/(\d+) (\w+) old/); if (!parts) return null; const amount = parseInt(parts[1]); const unit = parts[2]; const currentDate = new Date(); if (unit.includes("year")) { currentDate.setFullYear(currentDate.getFullYear() - amount); } else if (unit.includes("month")) { currentDate.setMonth(currentDate.getMonth() - amount); } else if (unit.includes("day")) { currentDate.setDate(currentDate.getDate() - amount); } return currentDate; } window.addEventListener('load', async function() { await delay(5000); // wait for other Javascript to do its magic console.log("Sorting..."); var projectsTab = document.getElementById("projects-tab"); array = Array.from(projectsTab.querySelectorAll("*[class^=\"item--\"]")) .sort((a, b) => { var firstDateStr = a.querySelectorAll("*[class^=\"itemDetailRow--\"]")[0].children[2].textContent; var secondDateStr = b.querySelectorAll("*[class^=\"itemDetailRow--\"]")[0].children[2].textContent; // Parse the date strings into Date objects var firstDate = parseDateFromString(firstDateStr); var secondDate = parseDateFromString(secondDateStr); // Compare the Date objects if (firstDate && secondDate) { return secondDate - firstDate; } else { // Handle cases where date parsing fails return 0; } }) .forEach(li => projectsTab.getElementsByTagName("li")[0].parentElement.appendChild(li)); console.log("Sorting completed!"); }, false);