How to make webshim work from greasemonkey userscript?

119 Views Asked by At

im making a userscript putting shims and polyfills into pages. i included Webshim too, except it doesnt seem to do anything.

this is how i included it:

var script = document.createElement("script");
script.src = "http://code.jquery.com/jquery-2.1.0.min.js";
var head = document.getElementsByTagName("head")[0];

head.insertBefore(script, head.firstChild);

var script = document.createElement("script");
script.src = "https://cdnjs.cloudflare.com/ajax/libs/webshim/1.16.0/minified/polyfiller.js";

head.insertBefore(script, head.firstChild);

var script = document.createElement("script");
script.innerHTML =
"webshims.setOptions('extendNative', true);webshims.polyfill();";

head.insertBefore(script, head.firstChild);

(insertBefore-ing since the script tags run when they are inserted anyway)

this causes webshim to apparently run, and without any errors. im trying it out on Firefox 3.x, which im pretty sure means it would have to shim a lot of things, except it doesnt seem to do anything at all. seeing in Firebug Net panel, it doesnt even seem to connect to any other .js files, only a shim-ext.css file. i went to webpages which clearly had video elements and other html5 things, and it still didnt do anything. i thought i had to put some special class names on the elements or something, but neither http://afarkas.github.io/webshim/demos/ or https://github.com/aFarkas/webshim or any stackoverflow posts or tutorials i found mention that. i thought the problem was that it couldnt find the other files, but it obviously could find shim-ext.css, and i found this way to include it on stackoverflow, with the only difference being that i run it in greasemonkey.

the userscript runs at 'document-start', and i checked that it runs before any other script and before the element even exists. if i specifically request a feature like 'webshim.polyfill('forms');' it still doesnt work or connect to anything. the usercript includes ECMAScript 5 shim&sham, ECMAScript 6 shim&sham and HTML5shiv in the page before Webshim, and its the latest version of everything. with and without setting basePath and extendNative, its still the same.

0

There are 0 best solutions below