Fix for window.open() links and replaced lines with a for-loop

Updated functionality to get links and files from javascript:window.open() links.
Also replaced a few lines with a for-loop (226-234).