Conversaciones » Peticiones de scripts
Is there any way to fix a script path before it is loaded in DOM?
Apologies. The syntax is:
Using greasemonkey's @run-at
metadata block you can have your userscript run before any scripts or images are loaded.
Developer notes: https://wiki.greasespot.net/Metadata_Block#.40run-at
Example script:// ==UserScript==
// @name Change Script Path
// @namespace http://tampermonkey.net/
// @version 0.1
// @description none
// @author none
// @match http*://example.org/*
// @grant none// @run-at document-start
// @noframes
// ==/UserScript==
(function() {
'use strict';
var scripts = document.getElementsByTagName("script");
for (var n = 0; n < scripts.length; n++) {
if (scripts[n].dataMain == "scripts/main") {
scripts[n].dataMain = "get?url=http://example.com/scripts/main&p=1";
}
}
})();
Is there any way to fix a script path before it is loaded in DOM?
There's a requireJS script using the following syntax:
RequireJS loads other script(s) from the entry point in data-main. However, the path value of data-main is broken.
I'd like to change "scripts/main" to "get?url=http://example.com/scripts/main&p=1" and therefore have it, when require.js executes, load from that path instead. Is this even possible with Greasemonkey?