I am writing a simple PhantomJS application that scratches certain pages that are looking for templates. On one of these pages, the site owner reads the width / height properties window.screenand changes the URL to me (which cancels loading the rest of the page). The setting viewportSizechanges the width / height of the window, but not the object screen.
Attempt 1
My first step is to turn off navigation, for example:
tab.onLoadStarted = function () {
tab.navigationLocked = true;
};
However, since this check is performed in <head>, it raises an event load, and sometimes the page is not yet fully loaded (which causes many other problems).
Attempt 2
I tried to override the display object on first boot:
tab.onLoadStarted = function () {
tab.evaluate(function () {
window.screen = {
width: 1920,
height: 1080
};
});
};
However, this property is read-only, so setting it does not change anything.
TL; DR
PhantomJS window.screen ?