Re:
Is there some way I can define window.devicePixelRatio
before the embedded script runs?
There is now. Like so:
// ==UserScript==
// @name _Pre set devicePixelRatio
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @run-at document-start
// @grant none
// ==/UserScript==
//-- @grant none is imporatant in this case.
window.devicePixelRatio = "Unimportant string or function or whatever";
In the general case:
Since Firefox version 4, this is now possible on Firefox only. Use the checkForBadJavascripts
utility to leverage the power of beforescriptexecute
. Like so:
// ==UserScript==
// @name _Block select inline JS
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require https://gist.github.com/raw/2620135/checkForBadJavascripts.js
// @run-at document-start
// @grant GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
introduced in GM 1.0. It restores the sandbox.
*/
checkForBadJavascripts ( [
[false, /window\.devicePixelRatio/, null]
] );
This blocks the first inline script, that contains window.devicePixelRatio
, entirely. If you want to selective modify parts of that script, see this answer and/or this answer.