Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8943787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:52:23+00:00 2026-06-15T11:52:23+00:00

I want to create a chrome extension to help me debug my swf, and

  • 0

I want to create a chrome extension to help me debug my swf, and I’d like the extension to be able to change some of the flashvars while keeping others untouched.

I can’t imagine this is a new or unique problem, so before I reinvent the wheel, I’m asking if anyone here has examples of it being done, or how to do it.

I’ve tried searching, but my googlefu seems to be off.

My use case is as follows. I have a Google Chrome extension which has a few drop down menus with possible flash var values. I want the change the values in the drop down, and then reload the swf with these new flashvars, but without changing flashvars which are not in my drop down menus.

I’m able to easily inject a new swf on the page with the values from my dropdown menus, however I’d like to be able to reload, rather than recreate, the swf.

I have tried using Jquery to pull all the flash vars like this:

var flashVars = $("param[name=flashvars]", gameSwfContainer).val();

However, I’m having a hard time changing or replacing just a couple of the values, and then injecting them back into the object. (Regex might be helpful here unless there is a better way?)

Thanks for your help.

Currently, I am trying to do the following, but I’m not sure if it’s the right direction.
ContentScript.js

//Setup
var swfVersionStr = "10.1.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var params = {};
    params.quality = "high";
    params.bgcolor = "#000000";
    params.allowscriptaccess = "always";
    params.allowfullscreen = "true";
var attributes = {};
    attributes.id = "game_swf_con";
    attributes.name = "game_swf_con";
    attributes.class = "game_swf_con";
    attributes.align = "middle";
var InjectedFlashvars = {
    "run_locally": "true",
        //.. some other flash vars that I won't be changing with my extension
    "swf_object_name":"game_swf"
};
// Injection code called when correct page and div detected;    
var injectScriptText = function(text)
    { 
                loopThroughLocalStorage();
                swfobject.embedSWF(
                    swfName, "game_swf_con",  
                    "760", "625", 
                    swfVersionStr, xiSwfUrlStr, 
                    InjectedFlashvars, params, attributes);
       swfobject.createCSS("#game_swf_con", "display:block;text-align:left;");
    };
        function loopThroughLocalStorage()
    {
        for(key in localStorage){
            try{
            var optionArray = JSON.parse(localStorage[key]);
            var option = returnSelectedFlashVar(optionArray);
            var value = option.value ? option.value : "";
            InjectedFlashvars[key] = value;
            } catch(err){}

        }
    }

    function returnSelectedFlashVar(optionArray){
        for(var i= 0; i < optionArray.length;i++)
        {
            if(optionArray[i].selected == true)
            {
                return optionArray[i];
            }
        }
    }

Overall, I currently have contentscript.js, background.js, options.js, options.html, popup.html and popup.js The code above so far only exists in contentscript.js

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:52:24+00:00Added an answer on June 15, 2026 at 11:52 am

    Had a little trouble deciding what you actually wanted.
    But if its manipulating the values in the flashvar maybe this will help…

    queryToObject = function(queryString) {
        var jsonObj = {};
        var e, a = /\+/g,
            r = /([^&=]+)=?([^&]*)/g,
            d = function(s) {
                return decodeURIComponent(s.replace(a, " "));
            };
    
        while(e = r.exec(queryString)) {
            jsonObj[d(e[1])] = d(e[2]);
        }
    
        return jsonObj;
    }
    
    objectToQuery = function(object) {
        var keys = Object.keys(object),
            key;
        var value, query = '';
        for(var i = 0; i < keys.length; i++) {
            key = keys[i];
            value = object[key];
            query += (query.length > 0 ? '&' : '') + key + '=' + encodeURIComponent(value);
        }
        return query;
    }
    
    // this is what a flashvar value looks like according to this page...http://www.mediacollege.com/adobe/flash/actionscript/flashvars.html
    var testQuery = 'myvar1=value1&myvar2=value2&myvar3=a+space';
    
    var testObject = queryToObject(testQuery);
    
    console.debug(testObject);
    
    testQuery = objectToQuery(testObject);
    
    console.debug(testQuery);
    
    testObject.myvar0 = 'bleh';
    
    delete testObject.myvar2;
    
    console.debug(objectToQuery(testObject));
    

    And if your using localStorage in a content script then be aware that the storage will be held in the context of the page.
    Try looking at chrome.storage instead.

    EDIT : Answer to comments
    This looks correct, but how do I "reload" the object so that those new flashvars are the ones that are used by the swf?

    Ive never used swfObject (havent done any flash stuff in like 5 years) but had a look and it looks like you can just rerun the swfobject.embedSWF with the new flashVars and it will replace the old object with the new one. Which is fine if your replacing one that you added yourself as you can supply all of the details, if your replacing something put there by someone else you could clone the object, change some stuff and replace the original with the clone. Cloning will not clone any events attached to the element but I dont think thats a problem in your case. Here’s an example (which I couldnt test as I couldnt find any simple sample swf that just prints the flashvars)….

    var target = document.querySelector('#game_swf_con');
    // Cloning the element will not clone any event listners attached to this element, but I dont think that's a prob for you
    var clone = target.cloneNode(true);
    var flashvarsAttribute = clone.querySelector('param[name=FlashVars]');
    if (flashvarsAttribute) {
        var flashvars = flashvarsAttribute.value;
        flashvars = queryToObject(flashvars);
        // add a new value
        flashvars.newValue = "something";
        // update the clone with the new FlashVars
        flashvarsAttribute.value = objectToQuery(flashvars);
        // replace the original object with the clone
        target.parentNode.replaceChild(clone, target);
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a bookmark extension in Chrome and I want to leverage
I'm trying to create an extension using this docs: http://code.google.com/chrome/extensions/content_scripts.html I want a part
I would like to create a google chrome extension. Specifically, I'd like to make
I want to create a Chrome extension that adds an option to the right
I want to create chrome extension crx file programatically (not using chrome.exe, because it
I am writing a Chrome extension where I am trying to create a GUI
I want to create an IE extension - a sidebar (Explorer bar) looking just
I'm trying to create a chrome extension and im doing this by parsing an
In my Chrome extension, I want to listen for changes to one particular tab
I have a chrome extension browser action that I want to have list a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.