GOG - Hide DLCs by default

Hide DLCs in the store page by default. Doesn't work on some links

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GOG - Hide DLCs by default
// @namespace    amekusa.gog-hide-dlcs
// @author       amekusa
// @version      1.0.1
// @description  Hide DLCs in the store page by default. Doesn't work on some links
// @match        https://www.gog.com/*
// @run-at       document-start
// @grant        none
// @license      MIT
// @homepage     https://github.com/amekusa/monkeyscripts
// ==/UserScript==

(function (doc) {
	// url params to add to the store links
	let params = 'hideDLCs=true';
	// params += '&discounted=true'; // option: Show only discounted
	// params += '&hideOwned=true';  // option: Hide all owned products

	let addParams = link => {
		let href = link.getAttribute('href');
		link.setAttribute('href', href + (href.includes('?') ? '&' : '?') + params);
	};
	let update = () => {
		let links = [];
		let exclude = `:not([href*="${params}"])`;
		links.push(doc.querySelectorAll('a[href$="/games"]' + exclude));
		links.push(doc.querySelectorAll('a[href*="/games?"]' + exclude));
		links.push(doc.querySelectorAll('a[href*="/games/"]' + exclude));
		// links.push(doc.querySelectorAll('a[href*="/promo/"]' + exclude));
		for (let i = 0; i < links.length; i++) links[i].forEach(addParams);
	};
	doc.addEventListener('DOMContentLoaded', update);
	doc.addEventListener('scrollend', update);

})(document);