I have some sort of idea.
Instead of keeping table with spell name -> buttons I could simply calculate the action slot on the fly by this:
Lua Code:
local slotID = rememberedActionSlot[spellName];
local bonusOffset = ((NUM_ACTIONBAR_PAGES + GetBonusBarOffset() - 1) * NUM_ACTIONBAR_BUTTONS);
slotID = slotID - bonusOffset;
local bar = math.floor(slotID / 10) + 1;
local btn = slotID % 10;
local button = _G['ElvUI_Bar' .. bar .. 'Button' .. btn];
If im not mistaken this should work on original blizzard ui, elvui, supervillian and bartender, buttonforge is completely off this grid so it would need to stay as it is.
Actually, I would just need to first 12 actions, not the rest of them since they are not changing. Am I correct?