Last active
February 6, 2023 19:20
-
-
Save mnixry/8f77e4fa658170561d6f7197ce7d6340 to your computer and use it in GitHub Desktop.
Userscript to highlight inactive group members with rainbow color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Highlight inactive group member | |
// @namespace https://gist.github.com/mnixry/ | |
// @version 0.1 | |
// @description Highlight inactive group members with rainbow color | |
// @author Mix | |
// @author yanyongyu | |
// @match https://qun.qq.com/member.html | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=qq.com | |
// @updateURL https://gist.github.com/mnixry/8f77e4fa658170561d6f7197ce7d6340/raw/highlight-inactive-member.user.js | |
// @downloadURL https://gist.github.com/mnixry/8f77e4fa658170561d6f7197ce7d6340/raw/highlight-inactive-member.user.js | |
// @supportURL https://gist.github.com/mnixry/8f77e4fa658170561d6f7197ce7d6340/#new_comment_field | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const MAX_DAY = 90 | |
setInterval( | |
()=>{ | |
const members = [...document.querySelectorAll('.mb')] | |
members | |
.forEach(m=>{ | |
const itime = m.querySelector('td:nth-child(8)').innerText; | |
const ltime = m.querySelector('td:nth-child(10)').innerText; | |
let idate, ldate; | |
try { | |
idate = Date.parse(itime); | |
ldate = Date.parse(ltime); | |
} catch (error) { | |
return | |
} | |
const diffDay = MAX_DAY - ( (ldate - idate) / (24 * 60 * 60 * 1000) ) | |
if (diffDay < 0) return | |
const hslValue = 160 * (MAX_DAY - diffDay) / MAX_DAY | |
const columns = [...m.querySelectorAll('dd td')] | |
columns.forEach(c=>(c.style.backgroundColor = `hsl(${hslValue},80%,90%)`)) | |
}) | |
}, | |
1000 | |
) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment