Author Topic: Help - Userscript to insert text into a flashvars attribute  (Read 995 times)

I am trying to use Userscript to insert an extra parameter into the attribute flashvars. I keep running into problems and added Alerts into the Userscript to test when things are being loaded. Not even the uncontained Alert was showing up - apparently this isn't even being loaded despite being the correct page.

My questions are: 1: What is required to get this to load on the correct page? I have the include set up for the exact webpage, and the non https one, so you'd think it'd work. 2: would setAttribute on the element I've found by name work for adding it?

Edit: I found that the missing "www." was making it not recognize. Still, even with the bottom bar saying the script is loading, I'm not even getting the bare alert out in the open of the code. Why isn't the script loading correctly?

Edit2: I'm coddled by most of Torque not caring between ' ' and " " (I know some does). And the alert in the insert code works, so I know that is being called. Now to the insert command...
« Last Edit: October 23, 2012, 05:34:01 PM by MegaScientifical »

post the entire script, including your includes?

also, if you Ctrl+Shift+I and click the Console tab, it'll show javascript errors.

Code: [Select]
function insertStupidity() {
// var flashstuff = document.getElementsByName("loader");
// var flashstuff = getObjectUS("loader");
var flashstuff = document.getElementsByTagName("embed");
alert('What is flashstuff? ' + flashstuff);
var flashvars = flashstuff.getAttribute("flashvars");
flashstuff.setAttribute("flashvars", flashstuff + "&isStupid=Yes");
}
insertStupidity();

It says getAttribute isn't a function. Using the alert, this is because the getElementsBy command isn't working right. It is returning [object HTMLCollection] or something. Could anyone figure out why it can't get it correctly? How to get it correctly?

getAttribute is only a property of a single element - getElementsByTagName returns an array of elements.

Well, I sort of gave up after talking with King over Steam. I can't figure out how to do it. The flash loads in an IFrame, so it's weird to mess with outside of manually inserting data.