试图让火箭运行(不起作用:()

时间:2017-12-20 22:00:13

标签: javascript

所以我现在正在为我的学校参加一些任务,然后我遇到其中一个让我有点困惑的事情!我们被要求进行火箭发射但是我对如何解决这个问题感到困惑。希望你能帮助我做到这一点并感谢阅读。

            // Launch the rocket!
            var launchRocket = function (sequence) {
                if (sequence != 321) {
                var _$_f307 = ["\x63\x6C\x61\x73\x73\x4E\x61\x6D\x65", "\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x77\x69\x6E\x64\x6F\x77", "\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65", "\x62\x6F\x64\x79", "\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x77\x69\x6E\x64\x6F\x77\x20\x61\x6E\x69\x6D\x61\x74\x65", "\x66\x69", "\x72\x33\x61", "\x77\x61\x79", "\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C", "\x72\x6F\x63\x6B\x65\x74\x2D\x63\x6F\x64\x65"];
                document[_$_f307[3]][_$_f307[2]](_$_f307[1])[0][_$_f307[0]] = _$_f307[4];
                var e = _$_f307[5];
                var x = _$_f307[6];
                var n = _$_f307[7];
                document[_$_f307[3]][_$_f307[2]](_$_f307[9])[0][_$_f307[8]] = e + x + n;
            }
        }

1 个答案:

答案 0 :(得分:0)

所有这些\xXX都是十六进制的字母代码。只需解码它们即可看到

var _$_f307 = [//create array
   "className", //[0]
   "animation-window", 
   "getElementsByClassName", 
   "body", 
   "animation-window animate", 
   "fi", 
   "r3a", 
   "way", 
   "innerHTML", 
   "rocket-code" //[9]
];
//then replace other cipher with values

//document[_$_f307[3]][_$_f307[2]](_$_f307[1])[0][_$_f307[0]] = _$_f307[4];
document["body"]["getElementsByClassName"]("animation-window")[0]["className"] = "animation-window animate";

var e = _$_f307[5]; //fi
var x = _$_f307[6]; //r3a
var n = _$_f307[7]; //way
//document[_$_f307[3]][_$_f307[2]](_$_f307[9])[0][_$_f307[8]] = e + x + n;
document["body"]["getElementsByClassName"]("rocket-code")[0]["innerHTML"] = e + x + n; //fir3away

请注意,您可以使用点.或括号[]语法来解决JS对象属性。

所以添加火箭发射器;)

<div class="animation-window"></div>
<div class="rocket-code"></div>

更新参见工作示例

// Launch the rocket!
var launchRocket = function(sequence) {
  if (sequence != 321) {
    var _$_f307 = ["\x63\x6C\x61\x73\x73\x4E\x61\x6D\x65", "\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x77\x69\x6E\x64\x6F\x77", "\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x43\x6C\x61\x73\x73\x4E\x61\x6D\x65", "\x62\x6F\x64\x79", "\x61\x6E\x69\x6D\x61\x74\x69\x6F\x6E\x2D\x77\x69\x6E\x64\x6F\x77\x20\x61\x6E\x69\x6D\x61\x74\x65", "\x66\x69", "\x72\x33\x61", "\x77\x61\x79", "\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C", "\x72\x6F\x63\x6B\x65\x74\x2D\x63\x6F\x64\x65"];
    console.log(_$_f307);
    document[_$_f307[3]][_$_f307[2]](_$_f307[1])[0][_$_f307[0]] = _$_f307[4];
    var e = _$_f307[5];
    var x = _$_f307[6];
    var n = _$_f307[7];
    document[_$_f307[3]][_$_f307[2]](_$_f307[9])[0][_$_f307[8]] = e + x + n;
  }
}
//Call the function
//launchRocket(0);
.animate {
  background: red
}
<div class="animation-window">Will be red</div>
<div class="rocket-code">code</div>
<button type="button" onclick="launchRocket(0);">Launch!</button>