First of all, there are plenty of great addons that do exactly what you want and only modify the buff container of nameplates while leaving the rest untouched. You can look them up here.
A minimal solution that doesn't include saving (so the /run command has to be executed after each UI reload) would be:
Code:
local whitelist = {
["Shadow Word: Pain"] = "player"
}
local function newShouldShowBuff(_,name,caster)
return name and (whitelist[name] == caster or whitelist[name] == "all")
end
local function Mixin(baseFrame)
baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
Mixin(baseFrame)
end
Only spells contained in the whitelist are shown on your nameplates. The values can either be "player" for auras that should only be shown if cast by the player or "all" for auras to be shown irrespective of the aura's source.Still, I can only repeat my initial recommendation of using a proper addon for this purpose.