theCrag - Select all routes

Checkbox to conveniently de-/select all routes when adding topos

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         theCrag - Select all routes
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Checkbox to conveniently de-/select all routes when adding topos
// @author       You
// @license      MIT 
// @match        https://www.thecrag.com/CIDS/cgi-bin/cids.cgi*AState=17515*
// @icon         https://www.google.com/s2/favicons?domain=thecrag.com
// @grant        none
// ==/UserScript==

// Check if the page has jQuery library
if (typeof jQuery == 'undefined') {
	var script = document.createElement('script')
	script.src = 'https://code.jquery.com/jquery-3.5.1.min.js'
	document.getElementsByTagName('head')[0].appendChild(script)
}

// Wait for jQuery to load
var checkJquery = setInterval(function () {
	if (typeof jQuery != 'undefined') {
		clearInterval(checkJquery)

		// Find the table by its class name
		var table = $('.process-table')

		// Add a checkbox to the header of the table
		table
			.find('thead tr')
			.prepend('<th><input type="checkbox" id="selectAll"></th>')

		// Select/Deselect all checkboxes on header checkbox change
		$('#selectAll').change(function () {
			$(table)
				.find('tbody input[type="checkbox"]')
				.prop('checked', this.checked)
		})
	}
}, 100)