This Google Ads Script will add negative keywords based on search term contains rules. Any search terms which meet search term filters (e.g. min impressions) and do NOT contain the necessary phrases will be added as negative keywords.
The project scope is here: https://docs.google.com/document/d/1mx5cJnEahJ_ONbPWQqvKpdWTQieM5-rp_xzM3D0FYoM/edit?pli=1