有办法在$.Get语句中使用Eval吗

Is There A Way To Use Eval in a $.Get Statement?

本文关键字:Eval 语句 Get      更新时间:2023-09-26

这是我的谷歌Chrome扩展的基本代码。如果你想看到这个扩展在运行,那么从他们的网站上下载,这样你就知道它是如何工作的了。扩展链路

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();
                }
            });
        }
    );
};

如果你注意到开头我有一个eval语句。我认为这只适用于实际的扩展本身,但我正在尝试使用:$.get。有没有办法加载该网页并切换该网页上的选项卡?如果有,如何切换?(标签位于底部,名为Gear、Shirts、Pants等)

我不能再发表评论了。所以我坚持这样。

为什么在URL上使用eval?Eval只能执行有效的JavaScript。这是一个强大但危险的过程。

你要求加载一个网页,我看到你确实使用了jQuery。我不太清楚你想达到什么目的。我不想临时安装这个扩展,因为它太耗时了。但是,您可以使用$.ajax以任何所需格式加载内容,包括纯文本和整个HTML树。这是非常强大的,因为它允许你在后台加载网站,并在用户不知情的情况下简化流程。

如果你提供更多信息,我可以为你的案件创建一个场景。

伊迪丝:

我现在通过脚本找到了一种以编程方式更改选项卡的方法。但我不知道你是否可以使用它。我不确定网站是如何获得信息的。你必须做一些测试。

然而,这就是我想到的:

您需要调用函数WebForm_DoPostBackWithOptions,并为所有可用的选项卡创建一个模式。例如,要在Google Chrome中请求Gears选项卡的内容,请尝试执行以下小片段:

// 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 ) );

我希望内容是使用AJAX加载的,这样你就可以找到内容加载的URL。这个网站真的让我很困惑。它提交的表单有效地加载了新内容,而没有重新加载和提交处理程序?我在这里看不到任何AJAX。如果是开发人员有意模糊代码,那么他完全成功了。

你会想考虑我在这里的另一篇文章,内容脚本的范围以及如何绕过对网站变量和函数的访问限制。

我希望你能解决这个问题。如果你真的想完成这个扩展,我相信你会找到办法的。但老实说,对于我只会处理几分钟的事情来说,这太费力了。