您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script fixes the issue that the PS Plus and EA Play links on the PS Store subscriptions page do not have a locale set.
当前为
- // ==UserScript==
- // @name PS Store Subscription Links Locale Fix
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description This script fixes the issue that the PS Plus and EA Play links on the PS Store subscriptions page do not have a locale set.
- // @author Nathaniel Wu
- // @match store.playstation.com/*
- // @license Apache-2.0
- // @supportURL https://gist.github.com/Nathaniel-Wu/2ff7fe939acca362d7fdeaf17b4f0d18
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- const in_iframe = () => {
- try {
- return window.self !== window.top;
- } catch (e) {
- return true;
- }
- }
- if (!in_iframe()) {
- const onSubscriptionPage = () => {
- return /^https?:\/\/store\.playstation\.com\/[^\/]+\/pages\/subscriptions($|\/)/g.test(window.location.href);
- };
- const fixSubscriptionLinks = () => {
- const locale = window.location.href.replace(/^https?:\/\/store\.playstation\.com\/([^\/]+)\/pages(\/.+)?$/g, '$1');
- document.querySelectorAll('.psw-solid-link.psw-button.psw-primary-button.psw-solid-button').forEach(e => {
- if (/(\/|\.)playstation\.com\/ps-plus($|\/)/g.test(e.href)) {
- // Fix the PS Plus link
- e.href = e.href.replace(/((\/|\.)playstation\.com\/)ps-plus/g, `$1${locale}/ps-plus`);
- } else if (/(\/|\.)playstation\.com\/eaplay($|\/)/g.test(e.href)) {
- // Fix the EA Play link
- e.href = e.href.replace(/((\/|\.)playstation\.com\/)eaplay/g, `$1${locale}/games/ea-play`);
- }
- });
- };
- if (onSubscriptionPage())
- fixSubscriptionLinks()
- let activeTransitions = 0;
- document.addEventListener('transitionend', (e) => {
- activeTransitions++;
- setTimeout(() => {
- activeTransitions--;
- if (activeTransitions == 0 && onSubscriptionPage())
- fixSubscriptionLinks();
- }, 200);
- });
- }
- })();