I was just wondering if there was any real easy way to go from a userscript that I have loaded in Scriptish to an unpacked extension in Chrome. I understand the hierarchy and the need for a manifest.json when dealing with an unpacked extension but I'm confused how to go between each other. I have a basic userscript that looks like this:
// ==UserScript==
// @id Random text field filler
// @include https://websitehere.com
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
document.getElementById("check box").checked = false;
waitForKeyElements ("[id='home_country']", myCountry);
function myCountry (jNode) {
var node = jNode[0];
for (var J = node.options.length - 1; J >= 0; --J) {
if (node.options[J].text==('US')) {
node.selectedIndex = J;
break;
}
}
}
document.getElementById('first_name').value="John"
document.getElementById('last_name').value="Doe"
This just selects US as a country from a dropdown and fills in some text fields on a website with names. How would I make this into something I could use in Chrome? I make use of the waitForKeyElements() function and am not sure if I can have that capability carry over. I was thinking of including the jquery.min and waitforkeyelements js files somehow in the manifest json. Is this possible? Any help or insight would be a great help. Thank you!
EDIT:
This is a simple demonstration of what I have going on. I'm just trying to get the text field's value to be my email on a checkout process. I'm also showing the logic I have for choosing the US as the country in the drop down box. This all works in Mozilla's add-ons.
If your content script's code should always be injected, register it in the extension manifest using the content_scripts
field, as in the following example.