The time limit hack is not a script, it has to be implemented in CHDK source. Only a few of the newer cameras are supported, the sx40 is not one of them.
However, OP is talking about 1...2 hours of uninterrupted video recording, in full HD. According to its specs, this camera records 4GB of full HD video in approx. 14.5 minutes. Since 4GB is a hard limit (a video file can't be larger than that), the recording bitrate would have to be lowered to approx. quarter of default (for 1 hour) or 1/8 of default (for a 2 hour recording).
The sx40 port does in theory support adjustment of video quality, but I don't know if that actually works for lowering bitrate. Also, I'm not sure if the visual quality of a reduced bitrate video would be sufficient to OP.