Add Download Button to TC4Shell.com 7-Zip Plugins Page

Some download links are manually processed AND they need my manual update to keep update with TC4Shell.com AND the last update is done at 2019-11-24.

目前為 2019-11-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Add Download Button to TC4Shell.com 7-Zip Plugins Page
// @description Some download links are manually processed AND they need my manual update to keep update with TC4Shell.com AND the last update is done at 2019-11-24.
// @namespace   RainSlide
// @author      RainSlide
// @match       http://www.tc4shell.com/en/7zip/
// @match       http://www.tc4shell.com/ru/7zip/
// @match       https://www.tc4shell.com/en/7zip/
// @match       https://www.tc4shell.com/ru/7zip/
// @note        HTTPS is not ready...
// @version     1.0
// @grant       none
// ==/UserScript==

document.head.appendChild( (css => {
	const style = document.createElement("style");
	style.textContent = css;
	return style;
})(`
#content h1 ~ div > h2 {
	display: flex;
	flex-flow: row nowrap;
	justify-content: space-between;
	align-items: center;
}

.button_7z_plugins_download {
	padding: .5em;
	box-sizing: content-box;
	height: 1em;
	line-height: 1;
	font-family: inherit;
	font-size: smaller;
	background: #e84c3d;
}
.button_7z_plugins_download:hover {
	background: #ff605f;
}
`.trim()) );

document.querySelectorAll('#content h1 ~ div > h2').forEach( h2 => {

	let filename = h2.textContent.split(" ")[0];
	// if ( [ "Asar7z", "Lzip7z" ].some( str => str === filename ) )
	// 	filename = filename.replace(/7z$/, "");
	if (filename === "Asar7z") filename = "Asar"; else
	if (filename === "Lzip7z") filename = "Lzip";

	const a = document.createElement("a");
	a.href = "/binary/" + filename + ".zip";
	a.setAttribute("download", "");
	a.className = "button button_7z_plugins_download";
	a.textContent = "Download";

	h2.appendChild(a);

} );