Add word count for small screens on alternatehistory.com.
目前為
// ==UserScript==
// @name AH mobile word count
// @description Add word count for small screens on alternatehistory.com.
// @author C89sd
// @version 1.0
// @match https://www.alternatehistory.com/*
// @namespace https://greasyfork.org/users/1376767
// ==/UserScript==
'use strict';
const links = document.querySelectorAll('div.structItem-minor > ul > li > a');
for (const link of links) {
if (link.textContent.startsWith('Word Count: ')) {
link.textContent = link.textContent.replace('Word Count: ', 'Words: ');
const parentThread = link.closest('div.structItem');
const mobileDate = parentThread.querySelector('div.structItem-cell--latest');
if (mobileDate) {
const middleDot = document.createElement('a');
middleDot.textContent = '·';
const gap = '0.5ch';
middleDot.style.marginRight = gap;
middleDot.style.marginLeft = gap;
mobileDate.append(middleDot);
mobileDate.append(link.cloneNode(true));
}
}
}