如何通过这个难题在JavaScript? [英] How to pass this puzzle in JavaScript?

查看:124
本文介绍了如何通过这个难题在JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友有一个在线的网页,它有一个内嵌脚本代码,还有一个JavaScript函数:

My friend has an online webpage, which it has an inline script tag, there is a JavaScript function:

(#1):

var domain = window.location.protocol + "//" + window.location.host + '/';

$(document).ready(function() {
    var count = 5;
    countdown = setInterval(function() {
        if (count == 0) {
            $('#countdow').hide();
            $('#link-news').show()
        } else {
            $('#countdow').text(count);
            count--
        }
    }, 1700);
    $('#link-news').click(function() {
        var urls = $('input[name=linknexttop]').val();
        if (urls == 1) {
            $('input[name=linknexttop]').val(2);
            $.ajax({
                type: "GET",
                url: domain + "click.html",
                data: "code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b",
                contentType: "application/json; charset=utf-8",

                success: function(html) {
                    //alert(html);
                    window.location = html;
                }
            })
        }
    })
});

他给了一个​​谜:?我可以运行低于code没有修改他原来的code

He has given a puzzle: "Can I run the below code without modified his original code?".

(2):

$('input[name=linknexttop]').val(2);
$.ajax({
        type: "GET",
        url: domain + "click.html",
        data: "code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b",
        contentType: "application/json; charset=utf-8",

        success: function(html) {
            //alert(html);
            window.location = html;
        }

规则玩:我允许插入我的code波纹管他原来的code而已;所以,我不能在他的code的修改,然后,最重要的是,<。 $ C C $> code = Sh9QA和放大器;记号= 0982ff3066a3c60dbd3ecf9bcafc801b 是随机的

要保存时间久等了,我已经使用这个<一href="https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?hl=en"相对=nofollow>扩展以prevent 倒计时(); ;而且,添加此code到它:

To save the time for waiting, I have used this extension to prevent the working of countdown();; and, add this code into it:

(#3):

$('#countdow').hide();
$('#link-news').show();


接下来,我试图去通过的url = $('输入[名称= linknexttop])VAL(); 。我试着用网​​址== 1; ;但是,我失败了。


Next , I tried to go to pass the urls = $('input[name=linknexttop]').val();. I tried with urls == 1;; but, I failed.

我的问题是:有什么办法来打发的url = $('输入[名称= linknexttop])VAL(); ,所有规则本场比赛被接受?。如果可能的话,请让我知道。

My question is: "Is there any way to pass the urls = $('input[name=linknexttop]').val();, with all rules of this game are accepted?". If it is possible, please let me know.

推荐答案

如果有问题的脚本是在内嵌剧本标签,你可以通过在循环找到它脚本,然后从中提取了code,并用它在你插入code。

If the script in question is in an inline script tag, you can find it by looping through the scripts and then extract the code from it, and use that in your inserted code.

沿着这些线路,你会插入一个脚本的东西元素:

Something along these lines, which you'd insert as a script element:

(function() {
    var code;
    $("script").each(function() {
        var match = /data=: "code=([^"]+)"/.exec($(this).text());
        if (match) {
            code = match[1];
            return false;
        }
    });
    $('#link-news').off("click");
    $('#link-news').click(function() {
        if (code) {
            $('input[name=linknexttop]').val(2);
            $.ajax({
                type: "GET",
                url: domain + "click.html",
                data: "code=" + code,
                contentType: "application/json; charset=utf-8",

                success: function(html) {
                    //alert(html);
                    window.location = html;
                }
            });
        }
    });
})();

在上面,我认为你应该的接管的从previous事件处理程序,而不是增加了。这是什么 .off(点击)一样。

In the above, I've assumed you're supposed to take over from the previous event handler, rather than adding to it. That's what the .off("click") does.

这篇关于如何通过这个难题在JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆