4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | function go() {
18 |
19 |
20 | var songs = [
21 | "your_music_path_1",
22 | "your_music_path_2",
23 | "......"
24 | ];
25 |
26 |
27 | function c() {
28 | var e = document.createElement("link");
29 | e.setAttribute("type", "text/css");
30 | e.setAttribute("rel", "stylesheet");
31 | e.setAttribute("href", f);
32 | e.setAttribute("class", l);
33 | document.body.appendChild(e)
34 | }
35 |
36 | function h() {
37 | var e = document.getElementsByClassName(l);
38 | for (var t = 0; t < e.length; t++) {
39 | document.body.removeChild(e[t])
40 | }
41 | }
42 |
43 | function p() {
44 | var e = document.createElement("div");
45 | e.setAttribute("class", a);
46 | document.body.appendChild(e);
47 | setTimeout(function() {
48 | document.body.removeChild(e)
49 | }, 100)
50 | }
51 |
52 | function d(e) {
53 | return {
54 | height : e.offsetHeight,
55 | width : e.offsetWidth
56 | }
57 | }
58 |
59 | function v(i) {
60 | var s = d(i);
61 | return s.height > e && s.height < n && s.width > t && s.width < r
62 | }
63 |
64 | function m(e) {
65 | var t = e;
66 | var n = 0;
67 | while (!!t) {
68 | n += t.offsetTop;
69 | t = t.offsetParent
70 | }
71 | return n
72 | }
73 |
74 | function g() {
75 | var e = document.documentElement;
76 | if (!!window.innerWidth) {
77 | return window.innerHeight
78 | } else if (e && !isNaN(e.clientHeight)) {
79 | return e.clientHeight
80 | }
81 | return 0
82 | }
83 |
84 | function y() {
85 | if (window.pageYOffset) {
86 | return window.pageYOffset
87 | }
88 | return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
89 | }
90 |
91 | function E(e) {
92 | var t = m(e);
93 | return t >= w && t <= b + w
94 | }
95 |
96 | function S() {
97 | var e = document.getElementById("audio_element_id");
98 | if(e != null){
99 | var index = parseInt(e.getAttribute("curSongIndex"));
100 | if(index > songs.length - 2) {
101 | index = 0;
102 | } else {
103 | index++;
104 | }
105 | e.setAttribute("curSongIndex", index);
106 | N();
107 | }
108 |
109 | e.src = i;
110 | e.play()
111 | }
112 |
113 | function x(e) {
114 | e.className += " " + s + " " + o
115 | }
116 |
117 | function T(e) {
118 | e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
119 | }
120 |
121 | function N() {
122 | var e = document.getElementsByClassName(s);
123 | var t = new RegExp("\\b" + s + "\\b");
124 | for (var n = 0; n < e.length; ) {
125 | e[n].className = e[n].className.replace(t, "")
126 | }
127 | }
128 |
129 | function initAudioEle() {
130 | var e = document.getElementById("audio_element_id");
131 | if(e === null){
132 | e = document.createElement("audio");
133 | e.setAttribute("class", l);
134 | e.setAttribute("curSongIndex", 0);
135 | e.id = "audio_element_id";
136 | e.loop = false;
137 | e.bgcolor = 0;
138 | e.addEventListener("canplay", function() {
139 | setTimeout(function() {
140 | x(k)
141 | }, 500);
142 | setTimeout(function() {
143 | N();
144 | p();
145 | for (var e = 0; e < O.length; e++) {
146 | T(O[e])
147 | }
148 | }, 15500)
149 | }, true);
150 | e.addEventListener("ended", function() {
151 | N();
152 | h();
153 | go();
154 | }, true);
155 | e.innerHTML = " If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.
";
156 | document.body.appendChild(e);
157 | }
158 | }
159 |
160 | initAudioEle();
161 | var e = 30;
162 | var t = 30;
163 | var n = 350;
164 | var r = 350;
165 |
166 | var curSongIndex = parseInt(document.getElementById("audio_element_id").getAttribute("curSongIndex"));
167 | var i = songs[curSongIndex];
168 |
169 | var s = "mw-harlem_shake_me";
170 | var o = "im_first";
171 | var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
172 | var a = "mw-strobe_light";
173 |
174 | /* harlem-shake-style.css,替换成你的位置,也可以直接使用://s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css */
175 | var f = "//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css";
176 |
177 | var l = "mw_added_css";
178 | var b = g();
179 | var w = y();
180 | var C = document.getElementsByTagName("*");
181 | var k = null;
182 | for (var L = 0; L < C.length; L++) {
183 | var A = C[L];
184 | if (v(A)) {
185 | if (E(A)) {
186 | k = A;
187 | break
188 | }
189 | }
190 | }
191 | if (A === null) {
192 | console.warn("Could not find a node of the right size. Please try a different page.");
193 | return
194 | }
195 | c();
196 | S();
197 | var O = [];
198 | for (var L = 0; L < C.length; L++) {
199 | var A = C[L];
200 | if (v(A)) {
201 | O.push(A)
202 | }
203 | }
204 | })()
--------------------------------------------------------------------------------