Set image quality

This commit is contained in:
redphx
2025-01-04 12:33:47 +07:00
parent 3fe6d97133
commit 097164b92e
7 changed files with 87 additions and 0 deletions

View File

@@ -1081,6 +1081,28 @@ ${subsVar} = subs;
return str;
},
*/
// 27.0.6-hotfix.1, 78831.js
setImageQuality(str: string) {
let index = str.indexOf('const{size:{width:');
index > -1 && (index = PatcherUtils.indexOf(str, '=new URLSearchParams', index, 500));
if (index < 0) {
return false;
}
const paramVar = PatcherUtils.getVariableNameBefore(str, index);
if (!paramVar) {
return false;
}
// Find "return" keyword
index = PatcherUtils.indexOf(str, 'return', index, 200);
const newCode = `${paramVar}.set('q', ${getPref(PrefKey.UI_IMAGE_QUALITY)});`;
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
};
let PATCH_ORDERS = PatcherUtils.filterPatches([
@@ -1094,6 +1116,8 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
'gameCardCustomIcons',
// 'gameCardPassTitle',
getPref(PrefKey.UI_IMAGE_QUALITY) < 90 && 'setImageQuality',
'modifyPreloadedState',
'optimizeGameSlugGenerator',