This would require a custom extension.
What about having your script included in all pages and let javascript act according to the type of page. Or you could add an inline script element to all pages which would load your external script according to the type of page.