0

Here is my basic code for this Google Chrome Extension. If you would like to see the extension in action, then download this off of their webstore, so you get an idea of how it works. Extension Link

function checkForHat() {
    $.get (
        'http://www.roblox.com/User.aspx?ID=1',

        function parse(data) {
            $(data).ready(function() {
                var epicness = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_AssetCategoryRepeater_ctl02_AssetCategorySelector');
                var epiclink = epicness.attr('href');
                eval(epiclink)
                var hatid1 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl00_AssetThumbnailHyperLink');
                var hatidtitle1 = hatid1.attr('title');
                var hatidhref1 = "http://www.roblox.com" + hatid1.attr('href');
                var hatidpi1 = $(hatid1).find('img')
                var hatidpic1 = hatidpi1.attr('src')
                hatLink1 = hatidhref1;
                hatTitle1 = hatidtitle1;
                hatPic1 = hatidpic1;
                var hatid2 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl01_AssetThumbnailHyperLink');
                var hatidtitle2 = hatid2.attr('title');
                var hatidhref2 = "http://www.roblox.com" + hatid2.attr('href');
                var hatidpi2 = $(hatid2).find('img')
                var hatidpic2 = hatidpi2.attr('src')
                hatLink2 = hatidhref2;
                hatTitle2 = hatidtitle2;
                hatPic2 = hatidpic2;
                var hatid3 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl02_AssetThumbnailHyperLink');
                var hatidtitle3 = hatid3.attr('title');
                var hatidhref3 = "http://www.roblox.com" + hatid3.attr('href');
                var hatidpi3 = $(hatid3).find('img')
                var hatidpic3 = hatidpi3.attr('src')
                hatLink3 = hatidhref3;
                hatTitle3 = hatidtitle3;
                hatPic3 = hatidpic3;
                if (hatLink3 != null && hatTitle3 != null && hatPic3 != null) {
                    checkIfNew3();
                }
                if (hatLink2 != null && hatTitle2 != null && hatPic2 != null) {
                    checkIfNew2();
                }
                if (hatLink1 != null && hatTitle1 != null && hatPic1 != null) {
                    checkIfNew1();
                }
            });
        }
    );
};

If you notice towards the beginning I have an eval statement. I think this only works on the actual extension itself, but what I'm trying to do is use: $.get. Is there a way to load that webpage and switch tabs on that webpage, if so, how? (The tabs are at the bottom named Gear, Shirts, Pants, etc.)

Jopc67
  • 79
  • 1
  • 6

1 Answers1

1

Again I cannot post comments. So I'm stuck to this way.

Why are you using eval on a URL? Eval can only execute valid JavaScript. It is a powerful but dangerous procedure.

You ask to load a webpage and I see you do use jQuery. I do not quite know what you are trying to achieve. And I do not want to temporarily install this extension for it is too time consuming. However, you can use $.ajax to load the content in any format you want, including plain text and entire HTML trees. This is very powerful as it allows you to load a website in the background and doing some simplification of processes without the user even knowing, for example.

If you provide some more information, I could create a scenario on your case.

EDITH:

I worked my way now through the scripts and found a way to programmatically change the tab. But I do not know if you can use it. I am unsure how the website obtains the information. You will have to do some testing.

However, this is what I've come up with:

You want to call the function WebForm_DoPostBackWithOptions and make a pattern for all the available tabs. For example, to request the contents of the Gears tab, in Google Chrome, try executing this little snippet:

// Save a pattern. We will have to replace the %n toward the end of the string.
var pattern = "ctl00$cphRoblox$rbxUserAssetsPane$AssetCategoryRepeater$ctl%n$AssetCategorySelector";

WebForm_DoPostBackWithOptions( new WebForm_PostBackOptions( pattern.replace( '%n', '02' ), '', true, '', '', false, true ) );

I hope the content is loaded using AJAX, so you could possibly find the URL the content is loading from. This website really confuses me. It submits a form effectively loading the new content without a reload and onsubmit handler? I don't see any AJAX here. If it was the developer's intention to obscure his code, he totally succeeded.

You will want to consider one of my other posts here about the scope of content scripts and how to bypass the access restriction on variables and functions of the website.

I hope you can work with this. If you really want to complete this extension, I'm sure you'll find a way. But to be honest, this is way too much effort for something that I'll be dealing with for only a couple of minutes.

Community
  • 1
  • 1
Kiruse
  • 1,703
  • 1
  • 12
  • 23
  • When I load the webpage (http://www.roblox.com/User.aspx?ID=1) it loads on the Hats tab, so it is extremely easy for me to get everything I need from it, but I can't get anything related to Gear, Pants, Shirts, etc because of how they do their coding. It makes it an extreme pain for me because there really is no real way to switch through the tabs to gear. They seem to be loading the content as you click through the tabs and not hiding it. If you would could you link me to an ajax tutorial? – Jopc67 Jan 29 '12 at 03:51
  • I've checked the website and I now do understand why you are trying to `eval` the href attribute. Give me some time on this, I'll look a little through the scripts, then I can probably provide a better solution. However, I've used [this](http://www.tizag.com/ajaxTutorial/) tutorial as AJAX was still quite uncommon but have just discovered that the w3schools also provide a [tutorial](http://www.w3schools.com/ajax/default.asp). – Kiruse Jan 29 '12 at 04:01