Questify: Some fixes and improvements. (#1123)
* Switch Find. * Support Quest Embeds + Fix Title/Subtitle Text. * Fix solo CTA button branch.
This commit is contained in:
parent
a3b3929071
commit
d84f700622
3 changed files with 47 additions and 3 deletions
|
|
@ -266,7 +266,7 @@ interface SettingsSwitchLayoutProps extends SwitchWithLabelProps {
|
|||
tooltip?: { position: "top" | "bottom", text: string; };
|
||||
}
|
||||
|
||||
const SwitchWithLabel = findComponentByCodeLazy('"data-toggleable-component":"switch"') as React.ComponentType<SwitchWithLabelProps>;
|
||||
const SwitchWithLabel = findComponentByCodeLazy('auxiliaryContentPosition:"under-label"') as React.ComponentType<SwitchWithLabelProps>;
|
||||
|
||||
export type SettingsSubtleSwitchProps = Omit<SettingsSwitchLayoutProps, "description">;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import { canAutoCompleteQuest, getActiveAutoCompletes, getQuestAutoCompleteProgr
|
|||
import { canOpenDevToolsWindow, fetchAndDispatchQuests, openDevToolsWindow, snakeToCamel } from "./utils/fetching";
|
||||
import { normalizeQuestName } from "./utils/filtering";
|
||||
import { notifyQuestCompletion, QL } from "./utils/logging";
|
||||
import { getQuestPanelOverride, getQuestPanelPercentComplete, shouldForceQuestPanelVisible } from "./utils/questState";
|
||||
import { getQuestEmbedProgress, getQuestPanelOverride, getQuestPanelPercentComplete, shouldForceQuestPanelVisible } from "./utils/questState";
|
||||
import { getLastFilterChoices, getLastSortChoice, getQuestTileClasses, getQuestTileStyle, setLastFilterChoices, setLastSortChoice, shouldPreloadQuestAssets, sortQuests } from "./utils/questTiles";
|
||||
import { formatLowerBadge, QUEST_PAGE } from "./utils/ui";
|
||||
|
||||
|
|
@ -114,6 +114,7 @@ export default definePlugin({
|
|||
getLastFilterChoices,
|
||||
getLastSortChoice,
|
||||
getQuestAutoCompleteProgress,
|
||||
getQuestEmbedProgress,
|
||||
getQuestButtonProps,
|
||||
getQuestPanelOverride,
|
||||
getQuestPanelPercentComplete,
|
||||
|
|
@ -405,6 +406,33 @@ export default definePlugin({
|
|||
// Force the CTA-aware complete branch.
|
||||
match: /(?<=analyticsCtxQuestContentRowIndex:\i}\)}\):\i&&\i)(.{0,200}?fullWidth:!0}\)}\):)(\i.enabled.{0,50}?CLAIMED\)&&\i.\i.has\(\i\))(\?\i=)(\i)/,
|
||||
replace: "&&false$1((arguments[0].quest.config.ctaConfig&&arguments[0].quest.userStatus?.completedAt)||($2))$3(true||$4)"
|
||||
},
|
||||
{
|
||||
// Prefer the CTA + progress button branch when Questify can complete the Quest.
|
||||
match: /(?<="data-migration-pending":.{0,100}?enabledQuestStates.has\(\i\)\?)/,
|
||||
replace: "!$self.canAutoCompleteQuest(arguments[0].quest)&&"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: "EMBED_DESKTOP}),",
|
||||
group: true,
|
||||
predicate: () => !getQuestifySettings().disableQuestsEverything,
|
||||
replacement: [
|
||||
{
|
||||
// Subscribes each Quest message embed to Questify's manual rerender trigger.
|
||||
match: /(?<=function \i\(\i\){)(?=let\{quest:\i,location:\i,questContentPosition:\i,sourceQuestContent:)/,
|
||||
replace: "void $self.useQuestRerender();"
|
||||
},
|
||||
{
|
||||
// Overrides the progress tracking for Quest embeds.
|
||||
match: /(?<=\{completedRatio:\i,completedRatioDisplay:\i\}=)(\(0,\i\.\i\)\((\i)\))/,
|
||||
replace: "Object.assign({},$1,$self.getQuestEmbedProgress($2)??{})"
|
||||
},
|
||||
{
|
||||
// Adds Questify tile classes and inline CSS variables.
|
||||
match: /(?<=className:)(\i\(\)\(\i.\i,\i.\i\)(?=,onMouseEnter:\i))/,
|
||||
replace: "$self.getQuestTileClasses($1,arguments[0].quest),style:$self.getQuestTileStyle(arguments[0].quest)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ interface QuestPanelPercentCompleteResult {
|
|||
percentCompleteText?: string;
|
||||
}
|
||||
|
||||
interface QuestEmbedProgressResult {
|
||||
completedRatio: number;
|
||||
completedRatioDisplay?: string;
|
||||
}
|
||||
|
||||
interface QuestProgressEntry {
|
||||
eventName?: QuestTaskType;
|
||||
heartbeat?: { lastBeatAt?: string | null; } | null;
|
||||
|
|
@ -151,12 +156,15 @@ function getCurrentIgnoredQuestIds(): string[] {
|
|||
}
|
||||
|
||||
function getAutoCompleteShowcaseQuest(): Quest | null {
|
||||
const entries = getActiveAutoCompletes();
|
||||
const runningEntries = entries.filter(entry => entry.status === "running");
|
||||
const showcaseEntries = runningEntries.length > 0 ? runningEntries : entries;
|
||||
let bestQuest: Quest | null = null;
|
||||
let bestTimeRemaining = Infinity;
|
||||
let currentQuest: Quest | null = null;
|
||||
let currentTimeRemaining = Infinity;
|
||||
|
||||
for (const entry of getActiveAutoCompletes()) {
|
||||
for (const entry of showcaseEntries) {
|
||||
const quest = QuestStore.getQuest(entry.questId);
|
||||
|
||||
if (!quest) {
|
||||
|
|
@ -275,6 +283,14 @@ export function getQuestPanelPercentComplete({
|
|||
};
|
||||
}
|
||||
|
||||
export function getQuestEmbedProgress(quest: Quest | null): QuestEmbedProgressResult | null {
|
||||
const progress = getQuestPanelPercentComplete({ quest, percentCompleteText: " " });
|
||||
|
||||
return progress
|
||||
? { completedRatio: progress.percentComplete, completedRatioDisplay: progress.percentCompleteText }
|
||||
: null;
|
||||
}
|
||||
|
||||
export function getQuestStatus(
|
||||
quest: Quest,
|
||||
ignoredQuestIds: ReadonlyArray<string>,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue