不显示已拥有游戏
不显示资料受限游戏
不显示DLC及原声带
`;
const targetElement = document.querySelector('.balanceTitle > div');
targetElement.appendChild(settings);
targetElement.appendChild(filter);
new Vue({
el: '#settings',
data() {
return {
reloadLimitedSaves_loading: false,
refershSaves_loading: false,
modal: false,
lastUpdateTime: Saves.lastupdatetime,
ownedApps: Saves.ownedApps.length,
wishlist: Saves.wishlist.length,
familygameList: Saves.familygameList.length,
limitedApps: limitedApps.length,
isInFamilyGroup: JSON.parse(localStorage.getItem('isInfamily')),
checkIsProfileFeatureLimited: JSON.parse(
localStorage.getItem('IsProfileFeatureLimited')
),
isSuspensionOff: JSON.parse(localStorage.getItem('isSuspensionOff')),
ownedAppsColor: localStorage.getItem('ownedColor'),
wishlistColor: localStorage.getItem('wishlistColor'),
familygameColor: localStorage.getItem('familygameColor'),
unownedColor: localStorage.getItem('unownedColor'),
defaultcolors: ['#0c8918', '#177cb0', '#ff8936', '#ff2e63'],
};
},
methods: {
updateValues() {
this.ownedApps = Saves.ownedApps.length;
this.wishlist = Saves.wishlist.length;
this.familygameList = Saves.familygameList.length;
this.limitedApps = limitedApps.length;
this.lastUpdateTime = Saves.lastupdatetime;
},
isInFamilyGroup_change(status) {
if (status) {
localStorage.setItem('isInfamily', JSON.stringify(true));
} else {
localStorage.removeItem('isInfamily');
}
},
checkIsProfileFeatureLimited_change(status) {
if (status) {
localStorage.setItem('IsProfileFeatureLimited', JSON.stringify(true));
Saves = GM_getValue('Saves');
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
} else {
localStorage.removeItem('IsProfileFeatureLimited');
const elements = document.querySelectorAll('.ProfileFeaturesLimited');
elements.forEach((element) => {
element.parentNode.removeChild(element);
});
}
},
isSuspensionOff_change(status) {
if (status) {
localStorage.setItem('isSuspensionOff', JSON.stringify(true));
GM_addStyle('.suspension{display:none}');
} else {
GM_addStyle('.suspension{display:block}');
localStorage.removeItem('isSuspensionOff');
}
},
ownedAppsColor_change(color) {
ownedColor = color;
localStorage.setItem('ownedColor', color);
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
},
wishlistColor_change(color) {
wishlistColor = color;
localStorage.setItem('wishlistColor', color);
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
},
familygameColor_change(color) {
familygameColor = color;
localStorage.setItem('familygameColor', color);
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
},
unownedColor_change(color) {
unownedColor = color;
localStorage.setItem('unownedColor', color);
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
},
async reloadSaves() {
this.$Notice.info({
title: '正在重载存档',
});
this.refershSaves_loading = true;
await Promise.all([
getOwnAndWish(),
this.isInFamilyGroup ? getFamilyGame() : Promise.resolve(),
]);
Saves = GM_getValue('Saves');
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
this.updateValues();
this.refershSaves_loading = false;
this.$Notice.success({
title: '重载完毕',
});
},
async reloadLimitedSaves() {
this.$Notice.info({
title: '正在加载受限游戏列表',
});
this.reloadLimitedSaves_loading = true;
await getLimitedGamesList();
limitedApps = GM_getValue('limitedApps');
this.updateValues();
this.reloadLimitedSaves_loading = false;
this.$Notice.success({
title: '加载完毕',
});
},
clearSaves() {
this.$Notice.info({
title: '存档已清除',
});
let nullSaves = {
wishlist: [],
ownedApps: [],
familygameList: [],
lastupdatetime: 0,
};
Saves = nullSaves;
GM_setValue('Saves', nullSaves);
this.updateValues();
},
},
});
new Vue({
el: '#filter',
data() {
return {
filter: [],
};
},
methods: {
filterChange() {
noownedGames = this.filter.includes('noOwnedGames');
noRestrictedGames = this.filter.includes('noRestrictedGames');
noDlc = this.filter.includes('noDlc');
const elements = document.querySelectorAll('.cdkGameIcon');
elements.forEach((element) => {
cdkeyGameChecker(element);
});
},
},
});
if (localStorage.getItem('isSuspensionOff') === 'true') {
GM_addStyle('.suspension{display:none}');
}
}
//游戏状态标记-CDKEY
function cdkeyGameChecker(element) {
const isAppOwned = (appId) => Saves.ownedApps.includes(appId);
const isAppinwishlist = (appId) => Saves.wishlist.includes(appId);
const isAppShared = (appId) => Saves.familygameList.includes(appId);
const isLimited = (appId) => limitedApps.includes(appId);
const getAppId = (url) => (url.match(/\/apps\/(\d+)\//) || [])[1] || null;
const getBundleId = (url) =>
(url.match(/\/bundles\/(\d+)\//) || [])[1] || null;
const appId = Number(getAppId(element.getAttribute('data-src')));
const gameNameElement = element
.closest('.gameblock')
.querySelector('.gameName');
if (appId != 0) {
element.parentElement.parentElement.style.display = 'block';
if (noDlc) {
getGameType(appId).then((type) => {
if (type === 'dlc' || type === 'music') {
element.parentElement.parentElement.style.display = 'none';
}
});
}
if (isAppOwned(appId)) {
if (noownedGames) {
element.parentElement.parentElement.style.display = 'none';
} else {
gameNameElement.style.color = ownedColor;
}
} else if (isAppShared(appId)) {
gameNameElement.style.color = familygameColor;
} else if (isAppinwishlist(appId)) {
gameNameElement.style.color = wishlistColor;
} else {
gameNameElement.style.color = unownedColor;
}
if (localStorage.getItem('IsProfileFeatureLimited')) {
const existingDiscountDiv = element.parentElement.querySelector(
'.ProfileFeaturesLimited'
);
if (existingDiscountDiv) {
existingDiscountDiv.remove();
}
if (isLimited(appId)) {
if (noRestrictedGames) {
element.parentElement.parentElement.style.display = 'none';
} else {
const discountDiv = document.createElement('div');
discountDiv.className = 'ProfileFeaturesLimited';
discountDiv.textContent = '资料受限';
element.parentElement.appendChild(discountDiv);
}
}
}
}
}
//加载存档
function load() {
var previousSave = GM_getValue('Saves');
if (previousSave !== undefined) {
Saves = GM_getValue('Saves');
} else {
GM_setValue('Saves', Saves);
}
var previousLimitedApps = GM_getValue('limitedApps');
if (previousLimitedApps !== undefined) {
limitedApps = GM_getValue('limitedApps');
} else {
getLimitedGamesList();
}
//自动更新
if (new Date().getTime() - Saves.lastupdatetime > 86400000) {
iview.Notice.info({
title: '存档自动更新中',
});
getOwnAndWish();
if (JSON.parse(localStorage.getItem('isInfamily'))) {
getFamilyGame();
}
getLimitedGamesList();
}
}
//监听页面变化
function observePageChanges() {
const config = {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['data-src'],
};
let hasExecuted = false;
const callback = function (mutationsList, observer) {
for (let mutation of mutationsList) {
if (
mutation.type === 'attributes' &&
mutation.attributeName === 'data-src'
) {
const targetElement = mutation.target;
if (targetElement.classList.contains('cdkGameIcon')) {
cdkeyGameChecker(targetElement);
}
}
if (!hasExecuted && mutation.type === 'childList') {
const balanceTitleElement = document.querySelector(
'.balanceTitle > div'
);
if (balanceTitleElement) {
init();
hasExecuted = true;
}
}
}
};
const observer = new MutationObserver(callback);
observer.observe(document.body, config);
}
//CSS样式
const style = document.createElement('style');
style.innerHTML = `
.ProfileFeaturesLimited {
width: .65rem;
height: .3rem;
background: #ed4014;
position: absolute;
top: 0;
color: #fff;
text-align: center;
line-height: .3rem;
font-size: .12rem;
}
`;
document.head.appendChild(style);
//默认颜色
if (!localStorage.getItem('ownedColor')) {
localStorage.setItem('ownedColor', '#0c8918');
localStorage.setItem('wishlistColor', '#177cb0');
localStorage.setItem('familygameColor', '#ff8936');
localStorage.setItem('unownedColor', '#ff2e63');
}
var ownedColor = localStorage.getItem('ownedColor');
var wishlistColor = localStorage.getItem('wishlistColor');
var familygameColor = localStorage.getItem('familygameColor');
var unownedColor = localStorage.getItem('unownedColor');
//Todo list:
//夜间模式
//侧栏收放
//中键快捷控制标签页
//左右翻页