You would do well to ascertain whether it is electricalor fuel in nature.
It is almost defo electrical, I would first when the engine is running do a wiggle test on all the connectors, especially the CPS connector, to see if it can be made to stop, chnces are it is a silly little bad joint break/somewhere.
As it only does it when it's hot this again is looking more likely to be electrical in nature.
tabetha