Best JavaScript code snippet using taiko
BUPTdaka.js
Source:BUPTdaka.js
...55 do {56 var home = text('å京é®çµå¤§å¦').className('android.view.View').depth(20).findOne(5000);57 count++;58 if (count > 2 && count <= 4) {59 scrollDown();60 sleep(1000);61 } else if (count > 4) {62 console.log("没ææ¾å°åé®å
¬ä¼å·");63 return false;64 }65 } while (home == null);66 var result1 = home.parent().parent().parent().parent().parent().click();67 console.log("æ¯å¦æå¼åé®å
¬ä¼å·:", result1);68 sleep(2000);69 //end format70 //2nd71 count = 0;72 do {73 var corona = textContains('ç«æ
é²æ§é').className('android.view.View').depth(20).findOne(5000);74 count++;75 if (count > 2 && count <= 4) {76 scrollDown();77 sleep(1000);78 } else if (count > 4) {79 console.log("没ææ¾å°å
¬ä¼å·çç«æ
é²æ§é");80 return false;81 }82 } while (corona == null);83 var result2 = corona.parent().parent().parent().parent().click();84 console.log("æ¯å¦æå¼å
¬ä¼å·çç«æ
é²æ§é:", result2);85 sleep(2000);86 // //2nd87 // var corona = id('com.tencent.mm:id/btf').row(0).depth(16).clickable(true).findOne(10000);88 // if (corona == null) {89 // console.log("没ææ¾å°ç«æ
é²æ§é");90 // return false;91 // }92 // var result2 = corona.click();93 // console.log("æ¯å¦æ¾å°ç«æ
é²æ§é:" + result2);94 // sleep(4000);95 //3rdç´æ¥ä»æ¯æ¥å¡«æ¥è¿å
¥96 count = 0;97 do {98 var daily = text('æ¯æ¥å¡«æ¥').className('android.widget.TextView').depth(12).findOne(5000);99 count++;100 sleep(1000);101 if (count > 4) {102 console.log("没ææ¾å°æ¯æ¥å¡«æ¥");103 return false;104 }105 } while (daily == null);106 var result3 = daily.parent().parent().click();107 console.log("æ¯å¦æå¼æ¯æ¥å¡«æ¥:", result3);108 sleep(3000);109 // //3rd110 // var daily = id('com.tencent.mm:id/gs1').row(-1).depth(10).clickable(true).indexInParent(0).findOne(10000);111 // if (daily == null) {112 // console.log("没ææ¾å°æ¯æ¥å¡«æ¥");113 // return false;114 // }115 // var result3 = daily.click();116 // console.log("æ¯å¦æ¾å°æ¯æ¥å¡«æ¥:" + result3);117 // sleep(5000);118 do {119 var dailyresult = text('æ¯æ¥å¡«æ¥').findOne(3000);120 scrollDown();121 } while (!dailyresult);122 return dailyresult;123}124//å¡«æ¥æ¯æ¥æå¡125function dailyonce() {126 scrollDown();127 sleep(1000);128 var dailyonce = text("æ¯æ¥å¡«æ¥").depth(22).findOne(10000);129 if (dailyonce == null) {130 console.log("没ææ¾å°æ¯æ¥å¡«æ¥æå¡è¿å
¥å£");131 return false;132 }133 var result3;134 do {135 result3 = dailyonce.parent().click();136 sleep(2000);137 } while (!result3);138 console.log("æ¯å¦æ¾å°æ¯æ¥å¡«æ¥æå¡è¿å
¥å£:" + result3);139 sleep(4000);140 scrollDown();141 //here starts the main part of the sheet142 //first choose ifatschool143 var ifatschool = text('ä»æ¥æ¯å¦å¨æ ¡ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);144 sleep(2000);145 var count = 0;146 var backcount = 0;147 while (!ifatschool) {148 scrollDown();149 ifatschool = text('ä»æ¥æ¯å¦å¨æ ¡ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);150 sleep(1000);151 count++;152 if (backcount == 2) {153 console.log('æ æ³æå¼ç½é¡µ!!');154 return false;155 }156 if (count == 2) {157 back();158 console.log('æå¡ç½é¡µæå¼å¤±è´¥,æ§è¡åéæä½');159 backcount++;160 sleep(2000);161 scrollDown();162 sleep(1000);163 //repeat of the former code, to refresh the landing page164 var dailyonce2 = className('android.view.View').row(9).depth(21).clickable(true).indexInParent(9).findOne(10000);165 if (dailyonce2 == null) {166 console.log("åéå,没ææ¾å°æ¯æ¥å¡«æ¥æå¡è¿å
¥å£");167 return false;168 }169 var res;170 do {171 res = dailyonce2.click();172 sleep(2000);173 } while (!res);174 console.log("åéå,æ¯å¦æ¾å°æ¯æ¥å¡«æ¥æå¡è¿å
¥å£:" + res);175 sleep(4000);176 count = 0;177 }178 }179 var result4 = ifatschool.parent().child(4).click();180 //important !!!181 //å¦æè¿æ ¡,éè¦èªè¡ä¿®æ¹!!!182 //å¨å®¶child(4)183 //å¨å¦æ ¡child(3)184 console.log("æ¯å¦éæ©äºæ¯å¦å¨æ ¡:" + result4);185 scrollDown();186 sleep(500);187 scrollDown();188 //now set the location189 var location = text('æå¨å°ç¹ï¼è¯·æå¼ææºä½ç½®åè½ï¼å¹¶å¨ææºæé设置ä¸éæ©å
许微信访é®ä½ç½®ä¿¡æ¯ï¼').depth(23).indexInParent(0).className('android.widget.TextView').findOne(10000);190 sleep(2000);191 while (!location) {192 scrollDown();193 location = text('æå¨å°ç¹ï¼è¯·æå¼ææºä½ç½®åè½ï¼å¹¶å¨ææºæé设置ä¸éæ©å
许微信访é®ä½ç½®ä¿¡æ¯ï¼').depth(23).indexInParent(0).className('android.widget.TextView').findOne(10000);194 sleep(1000);195 }196 var result5 = location.parent().click();197 sleep(2000);198 console.log("æ¯å¦è·åäºä½ç½®ä¿¡æ¯:" + result5);199 //æ¤å¤é®é¢:ç¹å»å¯¹è±¡åºè¯¥æ¯depth(22)çæ§ä»¶,ç¶èdepth(23)ä¹æ¯å¯ç¹å»ç,ä½æ¯ç¹å»æ æ!!!200 scrollDown();201 sleep(500);202 scrollDown();203 //now choose if at the risky location204 var risky = text('ä»æ¥æ¯å¦å¨ä¸é«é£é©å°åºï¼ï¼ä¸é«é£é©å°åºä¿¡æ¯å¯éè¿å½å¡é¢å®¢æ·ç«¯å°ç¨åºå®æ¶æ¥è¯¢ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);205 sleep(2000);206 while (!risky) {207 scrollDown();208 risky = text('ä»æ¥æ¯å¦å¨ä¸é«é£é©å°åºï¼ï¼ä¸é«é£é©å°åºä¿¡æ¯å¯éè¿å½å¡é¢å®¢æ·ç«¯å°ç¨åºå®æ¶æ¥è¯¢ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);209 sleep(1000);210 }211 var result6 = risky.parent().child(4).click();212 while (!result6) {213 scrollDown();214 result6 = risky.parent().child(4).click();215 }216 sleep(2000);217 console.log("æ¯å¦å¾éäºä¸å¨ä¸é«é£é©åº:" + result6);218 scrollDown();219 scrollDown();220 scrollDown();221 scrollDown();222 scrollDown();223 scrollDown();224 sleep(1000);225 scrollDown();226 scrollDown();227 scrollDown();228 scrollDown();229 scrollDown();230 scrollDown();231 sleep(1000);232 scrollDown();233 scrollDown();234 scrollDown();235 scrollDown();236 scrollDown();237 scrollDown();238 var submit = text('æ交信æ¯(Submit)').depth(21).indexInParent(0).findOne(4000);239 while (!submit) {240 scrollDown();241 submit = text('æ交信æ¯(Submit)').depth(21).indexInParent(0).findOne(4000);242 sleep(1000);243 }244 submit.click();245 sleep(2000);246 var confirm = textContains('确认').clickable(true).findOne(10000);247 sleep(1000);248 while (!confirm) {249 confirm = textContains('确认').clickable(true).findOne(10000);250 sleep(1000);251 }252 var finalresult = confirm.click();253 back();254 return finalresult;255}256//å¡«æ¥æ¨åææ£257function daily3times() {258 var daily3times = className('android.view.View').row(10).depth(21).clickable(true).indexInParent(10).findOne(10000);259 if (daily3times == null) {260 console.log("没ææ¾å°æ¯æ¥å¡«æ¥æå¡çé¢");261 return false;262 }263 var result3 = daily3times.click();264 console.log("æ¯å¦æ¾å°æ¯æ¥å¡«æ¥æå¡çé¢:" + result3);265 sleep(5000);266}267function verify() {268 scrollDown();269 sleep(1000);270 var verify = text("æ¯æ¥å¡«æ¥").depth(22).findOne(10000);271 if (verify == null) {272 return false;273 }274 var result1 = verify.parent().click();275 sleep(4000);276 scrollDown();277 //here is the copy of dailyonce278 //first choose ifatschool279 var ifatschool = text('ä»æ¥æ¯å¦å¨æ ¡ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);280 sleep(2000);281 while (!ifatschool) {282 scrollDown();283 ifatschool = text('ä»æ¥æ¯å¦å¨æ ¡ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);284 sleep(1000);285 }286 var result4 = ifatschool.parent().child(4).click();287 console.log("æ¯å¦éæ©äºæ¯å¦å¨æ ¡:" + result4);288 scrollDown();289 sleep(500);290 scrollDown();291 //now set the location292 var location = text('æå¨å°ç¹ï¼è¯·æå¼ææºä½ç½®åè½ï¼å¹¶å¨ææºæé设置ä¸éæ©å
许微信访é®ä½ç½®ä¿¡æ¯ï¼').depth(23).indexInParent(0).className('android.widget.TextView').findOne(10000);293 sleep(2000);294 while (!location) {295 scrollDown();296 location = text('æå¨å°ç¹ï¼è¯·æå¼ææºä½ç½®åè½ï¼å¹¶å¨ææºæé设置ä¸éæ©å
许微信访é®ä½ç½®ä¿¡æ¯ï¼').depth(23).indexInParent(0).className('android.widget.TextView').findOne(10000);297 sleep(1000);298 }299 var result5 = location.parent().click();300 sleep(2000);301 console.log("æ¯å¦è·åäºä½ç½®ä¿¡æ¯:" + result5);302 scrollDown();303 sleep(500);304 scrollDown();305 //now choose if at the risky location306 var risky = text('ä»æ¥æ¯å¦å¨ä¸é«é£é©å°åºï¼ï¼ä¸é«é£é©å°åºä¿¡æ¯å¯éè¿å½å¡é¢å®¢æ·ç«¯å°ç¨åºå®æ¶æ¥è¯¢ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);307 sleep(2000);308 while (!risky) {309 scrollDown();310 risky = text('ä»æ¥æ¯å¦å¨ä¸é«é£é©å°åºï¼ï¼ä¸é«é£é©å°åºä¿¡æ¯å¯éè¿å½å¡é¢å®¢æ·ç«¯å°ç¨åºå®æ¶æ¥è¯¢ï¼').depth(22).indexInParent(0).className('android.widget.TextView').findOne(10000);311 sleep(1000);312 }313 var result6 = risky.parent().child(4).click();314 while (!result6) {315 scrollDown();316 result6 = risky.parent().child(4).click();317 }318 sleep(2000);319 scrollDown();320 scrollDown();321 scrollDown();322 scrollDown();323 scrollDown();324 scrollDown();325 sleep(1000);326 scrollDown();327 scrollDown();328 scrollDown();329 scrollDown();330 scrollDown();331 scrollDown();332 sleep(1000);333 scrollDown();334 scrollDown();335 scrollDown();336 scrollDown();337 scrollDown();338 scrollDown();339 var submit = text('æ交信æ¯(Submit)').depth(21).indexInParent(0).findOne(4000);340 while (!submit) {341 scrollDown();342 submit = text('æ交信æ¯(Submit)').depth(21).indexInParent(0).findOne(4000);343 sleep(1000);344 }345 submit.click();346 sleep(2000);347 if (textContains('请确认信æ¯æ¯å¦å
¨é¨æ£ç¡®').exists()) {348 return false;349 } else if (textContains('ä½ å·²æ交è¿').exists()) {350 return true;351 } else { return false; }352}353//main function code354// console.show();355// console.setPosition(255, 525);...
faucets.py
Source:faucets.py
1import tools2import datetime3from commands import Commands4import time5import os6import OCR7import inspect8def bitcoinker():9 '''10 Recipe name: bitcoinker11 ''' 12 _iamnotarobot_ = "assets/iamnotarobot"13 _iamnotarobot_done_ = "assets/iamnotarobot-done"14 config = tools.JSON.get("config.json")15 links = config["links"]16 cmd = Commands()17 cmd.is_animation_on = True18 cmd.animation_time = 0.0119 selected_link = "bitcoinker"20 cmd.link(links[selected_link])21 cmd.wait_for("HTML is done?", f'assets/{selected_link}/htmlisdone.png', scrolldown_enabled=False)22 if cmd.solve_recaptcha():23 print("solve_recaptcha fail")24 tools.Logging.fail(f"logs/time/{selected_link}.txt", "solve_recaptcha fail")25 cmd.link("localhost")26 exit()27 28 if cmd.wait_for("Waiting process done", _iamnotarobot_done_, scrolldown_enabled=False):29 cmd.link("localhost")30 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Process done yakalanamadı.")31 exit()32 if not cmd.wait_for("Claim edilcek.", f'assets/bitcoinker/claim_bitcoin', scrolldown_enabled=True, sensitive=True):33 cmd.find_and_click(f'assets/bitcoinker/claim_bitcoin', sensitive=True)34 time.sleep(2)35 cmd.payment_solver(selected_link, sensitive=True)36 tools.Logging.success(f"logs/time/{selected_link}.txt")37 else:38 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Claim edilemedi!")39 cmd.link("localhost")40def bitfun():41 '''42 Recipe name: bitcoinker43 ''' 44 _iamnotarobot_ = "assets/iamnotarobot"45 _iamnotarobot_done_ = "assets/iamnotarobot-done"46 config = tools.JSON.get("config.json")47 links = config["links"]48 cmd = Commands()49 cmd.is_animation_on = True50 cmd.animation_time = 0.0151 selected_link = "bitfun"52 cmd.link(links[selected_link])53 cmd.wait_for("HTML is done?", f'assets/{selected_link}/htmlisdone', scrolldown_enabled=False)54 cmd.wait_for("Searching claim button?", f'assets/{selected_link}/claim', scrolldown_enabled=True, sensitive=True)55 cmd.find_and_click(f'assets/{selected_link}/claim', sensitive=True)56 57 if cmd.solve_recaptcha(firstly_go_to_top=False):58 print("solve_recaptcha fail")59 tools.Logging.fail(f"logs/time/{selected_link}.txt", "solve_recaptcha fail")60 cmd.link("localhost")61 exit()62 63 time.sleep(2)64 cmd.find_and_click(f'assets/{selected_link}/claim', sensitive=True)65 time.sleep(2)66 67 if not cmd.wait_for("Searching claim button?", f'assets/{selected_link}/close', scrolldown_enabled=False, sensitive=True):68 cmd.find_and_click(f'assets/{selected_link}/close', sensitive=True)69 tools.Logging.success(f"logs/time/{selected_link}.txt")70 else:71 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Claim edilemedi!")72 cmd.link("localhost")73def bonusbitcoin():74 '''75 Recipe name: bonusbitcoin76 '''77 _iamnotarobot_ = "assets/iamnotarobot"78 _iamnotarobot_done_ = "assets/iamnotarobot-done"79 config = tools.JSON.get("config.json")80 links = config["links"]81 cmd = Commands()82 cmd.is_animation_on = True83 cmd.animation_time = 0.0184 selected_link = "bonusbitcoin"85 86 cmd.link(links[selected_link])87 cmd.wait_for("HTML is done?", f'assets/{selected_link}/htmlisdone.png', scrolldown_enabled=False)88 89 cmd.wait_for("I'am not a robot bulunacak.",_iamnotarobot_, scrolldown_enabled=True, sensitive=False)90 if cmd.solve_recaptcha(scrolldown_enabled=False, firstly_go_to_top=False):91 print("solve_recaptcha fail")92 tools.Logging.fail(f"logs/time/{selected_link}.txt", "solve_recaptcha fail")93 cmd.link("localhost")94 exit()95 96 cmd.wait_for("Waiting process done", _iamnotarobot_done_, scrolldown_enabled=False)97 if not cmd.wait_for("Claim edilcek.", f'assets\{selected_link}\claim_now.png', scrolldown_enabled=True, sensitive=True):98 time.sleep(2)99 cmd.find_and_click(f'assets\{selected_link}\claim_now.png', sensitive=True)100 #cmd.payment_solver(selected_link, sensitive=True)101 tools.Logging.success(f"logs/time/{selected_link}.txt")102 else:103 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Claim edilemedi!")104 cmd.link("localhost")105def freebitco():106 '''107 Recipe name: freebitco108 '''109 _iamnotarobot_ = "assets/iamnotarobot"110 _iamnotarobot_done_ = "assets/iamnotarobot-done"111 config = tools.JSON.get("config.json")112 links = config["links"]113 cmd = Commands()114 cmd.is_animation_on = True115 cmd.animation_time = 0.01116 selected_link = "freebitco"117 118 cmd.link(links[selected_link])119 cmd.wait_for("HTML is done?", f'assets/{selected_link}/htmlisdone.png', scrolldown_enabled=False)120 cmd.mouse.position = config["location"]["temp"]121 cmd.click_l()122 if cmd.solve_recaptcha():123 print("solve_recaptcha fail")124 tools.Logging.fail(f"logs/time/{selected_link}.txt", "solve_recaptcha fail")125 cmd.link("localhost")126 exit()127 128 cmd.wait_for("Waiting process done", _iamnotarobot_done_, scrolldown_enabled=False)129 if not cmd.wait_for("Roll edilcek.", f'assets/{selected_link}/roll.png', scrolldown_enabled=True, sensitive=True):130 cmd.find_and_click(f'assets/{selected_link}/roll.png', sensitive=True)131 time.sleep(2)132 cmd.mouse.position = config["location"]["temp"]133 cmd.click_l()134 #cmd.payment_solver(selected_link, sensitive=True)135 tools.Logging.success(f"logs/time/{selected_link}.txt")136 137 else:138 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Claim edilemedi!")139 cmd.link("localhost")140def moon(selected_link):141 f'''142 Recipe name: {selected_link}143 '''144 this_func = eval(inspect.stack()[0][3])145 def check():146 if "blank" in OCR.resolve_url():147 print("! RESET")148 return this_func(selected_link)149 else:150 if OCR.check_current_url():151 time.sleep(1)152 cmd = Commands()153 cmd.go_to_top()154 BASE_ASSET_DIR = f'assets/__faucets__/{selected_link}'155 _iamnotarobot_ = "assets/iamnotarobot"156 _iamnotarobot_done_ = "assets/iamnotarobot-done"157 config = tools.JSON.get("config.json")158 links = config["links"]159 cmd = Commands()160 cmd.is_animation_on = True161 cmd.animation_time = 0.01162 163 cmd.link(links[selected_link])164 cmd.wait_for("HTML is done?", os.path.join(BASE_ASSET_DIR, "htmlisdone"), scrolldown_enabled=False)165 cmd.mouse.position = config["location"]["temp"]166 cmd.click_l(close_after_click=False)167 time.sleep(5)168 check()169 time.sleep(2)170 # Double Close Check171 if not cmd.wait_for("Reklam Kapatılacak.", os.path.join(BASE_ASSET_DIR, 'close'), scrolldown_enabled=False, sensitive=True):172 cmd.find_and_click(os.path.join(BASE_ASSET_DIR, 'close'), sensitive=True, close_after_click=False)173 time.sleep(2)174 check()175 time.sleep(2)176 if not cmd.wait_for("Reklam Kapatılacak.", os.path.join(BASE_ASSET_DIR, 'close'), scrolldown_enabled=False, sensitive=True, timeout=10):177 cmd.find_and_click(os.path.join(BASE_ASSET_DIR, 'close'), sensitive=True, close_after_click=False)178 time.sleep(2)179 check()180 time.sleep(2)181 ###.............182 if not cmd.wait_for("Claim edilcek.", os.path.join(BASE_ASSET_DIR, 'claim'), scrolldown_enabled=True, sensitive=True):183 cmd.find_and_click(os.path.join(BASE_ASSET_DIR, 'claim'), sensitive=True, close_after_click=False)184 time.sleep(2)185 check()186 if cmd.solve_recaptcha(scrolldown_enabled=False, firstly_go_to_top=False):187 print("solve_recaptcha fail")188 tools.Logging.fail(f"logs/time/{selected_link}.txt", "solve_recaptcha fail")189 cmd.link("localhost")190 exit()191 192 cmd.wait_for("Waiting process done", _iamnotarobot_done_, scrolldown_enabled=False)193 if not cmd.wait_for("Claim edilcek.", os.path.join(BASE_ASSET_DIR, 'claim'), scrolldown_enabled=True, sensitive=True):194 cmd.find_and_click(os.path.join(BASE_ASSET_DIR, 'claim'), sensitive=True, close_after_click=False)195 time.sleep(2)196 check()197 tools.Logging.success(f"logs/time/{selected_link}.txt")198 else:199 tools.Logging.fail(f"logs/time/{selected_link}.txt", "Claim edilemedi!")200 201 time.sleep(5)202 cmd.link("localhost")...
discover.js
Source:discover.js
1$(document).ready(function () {2 let current=1;3 $('#box'+current).css('width','100%')4 $('#s1c'+current).css('display','grid')5 $('#li1').click(function () {6 $('#box'+current).css('width','0%')7 $('#s1c'+current).css('display','none')8 current=19 $('#box'+current).css('width','100%')10 $('#s1c'+current).css('display','grid')11 });12 $('#li2').click(function () {13 $('#box'+current).css('width','0%')14 $('#s1c'+current).css('display','none')15 current=216 $('#box'+current).css('width','100%')17 $('#s1c'+current).css('display','grid')18 });19 $('#li3').click(function () {20 $('#box'+current).css('width','0%')21 $('#s1c'+current).css('display','none')22 current=323 $('#box'+current).css('width','100%')24 $('#s1c'+current).css('display','grid')25 });26 $('#li4').click(function () {27 $('#box'+current).css('width','0%')28 $('#s1c'+current).css('display','none')29 current=430 $('#box'+current).css('width','100%')31 $('#s1c'+current).css('display','grid')32 });33 $('#li5').click(function () {34 $('#box'+current).css('width','0%')35 $('#s1c'+current).css('display','none')36 current=537 $('#box'+current).css('width','100%')38 $('#s1c'+current).css('display','grid')39 });40 $('#li6').click(function () {41 $('#box'+current).css('width','0%')42 $('#s1c'+current).css('display','none')43 current=644 $('#box'+current).css('width','100%')45 $('#s1c'+current).css('display','grid')46 });47 48 $('#btn_hscroll').click(function () {49 $('html,body').animate({50 scrollTop: $('#section1').offset().top51 },1000);52 });53 $('#btn_secscroll').click(function () {54 $('html,body').animate({55 scrollTop: $('#section1').offset().top56 }, 1000)57 })58 ///////////////////////////////////// ScrollMagic59 var controller = new ScrollMagic.Controller();60 if(document.body.clientWidth <= 320){61 new ScrollMagic.Scene({62 triggerElement: '#section1',63 offset: 45064 }).setClassToggle('.con_scroll','fixed').addTo(controller).reverse(true);65 new ScrollMagic.Scene({66 triggerElement: '#footer',67 offset: -40068 }).setClassToggle('.con_scroll','absolute').addTo(controller).reverse(true);69 70 }71 else if(document.body.clientWidth <= 768){72 new ScrollMagic.Scene({73 triggerElement: '#section1',74 offset: 45075 }).setClassToggle('.con_scroll','fixed').addTo(controller).reverse(true)76 new ScrollMagic.Scene({77 triggerElement: '#footer',78 offset: -40079 }).setClassToggle('.con_scroll','absolute').addTo(controller).reverse(true);80 }81 else{82 new ScrollMagic.Scene({83 triggerElement: '#section1',84 offset: 450, duration: 250085 }).setClassToggle('.con_scroll','fixed').addTo(controller).reverse(true);86 }87 $('.scrolldown').click(function () {88 new TimelineMax()89 .addLabel('a')90 .to('.ul_s',0.5,{ opacity: "1"})91 .to('.scrolldown',0.3,{ opacity:'0',ease:'power2.inOut'},"a")92 .to('.scrolldown',0,{ display: 'none'},"a+=0.25")93 .to('.scrollup',0.3,{ opacity: '1',ease:'power2.inOut'},"a+=0.25")94 })95 $('.scrollup').click(function () {96 new TimelineMax()97 .addLabel('b')98 .to('.ul_s',0.25,{ opacity: "0"})99 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"b")100 .to('.scrolldown',0,{ display: 'block'},"b+=0.25")101 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"b+=0.25")102 })103 104 $('#li_s_1').click(function () {105 new TimelineMax()106 .addLabel('c')107 .to('.ul_s',0.5,{ opacity: "0"})108 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")109 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")110 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")111 $('#s1c'+current).css('display','none')112 current=1113 $('#s1c'+current).css('display','grid')114 $('#t_li_current').html("ALL")115 })116 $('#li_s_2').click(function () {117 new TimelineMax()118 .addLabel('c')119 .to('.ul_s',0.5,{ opacity: "0"})120 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")121 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")122 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")123 $('#s1c'+current).css('display','none')124 current=2125 $('#s1c'+current).css('display','grid')126 $('#t_li_current').html("POP")127 })128 $('#li_s_3').click(function () {129 new TimelineMax()130 .addLabel('c')131 .to('.ul_s',0.5,{ opacity: "0"})132 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")133 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")134 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")135 $('#s1c'+current).css('display','none')136 current=3137 $('#s1c'+current).css('display','grid')138 $('#t_li_current').html("ROCK")139 })140 $('#li_s_4').click(function () {141 new TimelineMax()142 .addLabel('c')143 .to('.ul_s',0.5,{ opacity: "0"})144 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")145 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")146 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")147 $('#s1c'+current).css('display','none')148 current=4149 $('#s1c'+current).css('display','grid')150 $('#t_li_current').html("COUNTRY")151 })152 $('#li_s_5').click(function () {153 new TimelineMax()154 .addLabel('c')155 .to('.ul_s',0.5,{ opacity: "0"})156 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")157 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")158 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")159 $('#s1c'+current).css('display','none')160 current=5161 $('#s1c'+current).css('display','grid')162 $('#t_li_current').html("HIP HOP")163 })164 $('#li_s_6').click(function () {165 new TimelineMax()166 .addLabel('c')167 .to('.ul_s',0.5,{ opacity: "0"})168 .to('.scrollup',0.3,{ opacity:'0',ease:'power2.inOut'},"c")169 .to('.scrolldown',0,{ display: 'block'},"c+=0.25")170 .to('.scrolldown',0.3,{ opacity: '1',ease:'power2.inOut'},"c+=0.25")171 $('#s1c'+current).css('display','none')172 current=6173 $('#s1c'+current).css('display','grid')174 $('#t_li_current').html("EDM")175 })...
scroll-animate.test.js
Source:scroll-animate.test.js
...11 const fixture = createFixture(12 scrollAnimate, { previousClassName, animationClass }13 )14 expect(fixture.getClassName()).toBe(previousClassName)15 fixture.scrollDown(true)16 expect(fixture.getClassName()).not.toBeNull()17 expect(fixture.getClassNames()).toContain(previousClassName)18 })19 })20 describe('Non-directional', () => {21 const animationClass = 'flip'22 test('should add animation classes', () => {23 const fixture = createFixture(scrollAnimate, { animationClass })24 expect(fixture.getClassName()).toBeFalsy()25 fixture.scrollDown(true)26 expect(fixture.getClassName()).toEqual(animationClass)27 })28 test('should toggle animation when repeat is on', () => {29 const fixture = createFixture(30 scrollAnimate, { animationClass, repeat: true }31 )32 expect(fixture.getClassName()).toBeFalsy()33 fixture.scrollDown(true)34 expect(fixture.getClassName()).toEqual(animationClass)35 fixture.scrollDown(false)36 expect(fixture.getClassName()).toBeFalsy()37 fixture.scrollUp(true)38 expect(fixture.getClassName()).toEqual(animationClass)39 })40 41 test('should not toggle animation when repeat is off', () => {42 const fixture = createFixture(43 scrollAnimate, { animationClass, repeat: false }44 )45 expect(fixture.getClassName()).toBeFalsy()46 fixture.scrollDown(true)47 expect(fixture.getClassName()).toEqual(animationClass)48 fixture.scrollDown(false)49 expect(fixture.getClassName()).toEqual(animationClass)50 fixture.scrollUp(true)51 expect(fixture.getClassName()).toEqual(animationClass)52 fixture.scrollUp(false)53 fixture.scrollDown(true)54 fixture.scrollDown(false)55 expect(fixture.getClassName()).toEqual(animationClass)56 })57 })58 describe('Downwards animation', () => {59 const animationClass = {down: 'rotate'}60 test('should apply animation on scroll once', () => {61 const fixture = createFixture(scrollAnimate, { animationClass })62 expect(fixture.getClassName()).toBeFalsy()63 fixture.scrollDown(true)64 expect(fixture.getClassName()).toEqual(animationClass.down)65 fixture.scrollDown(false)66 expect(fixture.getClassName()).toEqual(animationClass.down)67 fixture.scrollUp(true)68 expect(fixture.getClassName()).toEqual(animationClass.down)69 fixture.scrollUp(false)70 expect(fixture.getClassName()).toEqual(animationClass.down)71 })72 test('should toggle animation when repeat is on', () => {73 const fixture = createFixture(74 scrollAnimate, { animationClass, repeat: true }75 )76 expect(fixture.getClassName()).toBeFalsy()77 fixture.scrollDown(true)78 expect(fixture.getClassName()).toEqual(animationClass.down)79 fixture.scrollDown(false)80 expect(fixture.getClassName()).toEqual(animationClass.down)81 fixture.scrollUp(true)82 fixture.scrollUp(false)83 expect(fixture.getClassName()).toBeFalsy()84 fixture.scrollDown(true)85 expect(fixture.getClassName()).toEqual(animationClass.down)86 })87 })88 describe('Upwards animation', () => {89 const animationClass = { up: 'jackInTheBox' }90 test('should apply animation on scroll once', () => {91 const fixture = createFixture(scrollAnimate, { animationClass })92 expect(fixture.getClassName()).toBeFalsy()93 fixture.scrollDown(true)94 expect(fixture.getClassName()).toBeFalsy()95 fixture.scrollDown(false)96 expect(fixture.getClassName()).toBeFalsy()97 fixture.scrollUp(true)98 expect(fixture.getClassName()).toEqual(animationClass.up)99 fixture.scrollUp(false)100 expect(fixture.getClassName()).toEqual(animationClass.up)101 fixture.scrollDown(true)102 expect(fixture.getClassName()).toEqual(animationClass.up)103 fixture.scrollDown(false)104 expect(fixture.getClassName()).toEqual(animationClass.up)105 })106 test('should toggle animation when repeat is on', () => {107 const fixture = createFixture(108 scrollAnimate, { animationClass, repeat: true }109 )110 expect(fixture.getClassName()).toBeFalsy()111 fixture.scrollDown(true)112 expect(fixture.getClassName()).toBeFalsy()113 fixture.scrollDown(false)114 expect(fixture.getClassName()).toBeFalsy()115 fixture.scrollUp(true)116 expect(fixture.getClassName()).toBe(animationClass.up)117 fixture.scrollUp(false)118 expect(fixture.getClassName()).toBe(animationClass.up)119 fixture.scrollDown(true)120 fixture.scrollDown(false)121 expect(fixture.getClassName()).toBeFalsy()122 fixture.scrollUp(true)123 expect(fixture.getClassName()).toBe(animationClass.up)124 fixture.scrollUp(false)125 fixture.scrollDown(true)126 fixture.scrollDown(false)127 expect(fixture.getClassName()).toBeFalsy()128 })129 })130 describe('Bi-directional animation', () => {131 const animationClass = {up: 'zoomIn', down: 'zoomOut'}132 test('should toggle appropriate direction', () => {133 const fixture = createFixture(scrollAnimate, { animationClass })134 expect(fixture.getClassName()).toBeFalsy()135 fixture.scrollDown(true)136 expect(fixture.getClassName()).toBe(animationClass.down)137 fixture.scrollDown(false)138 expect(fixture.getClassName()).toBe(animationClass.down)139 fixture.scrollUp(true)140 expect(fixture.getClassName()).toBe(animationClass.up)141 fixture.scrollUp(false)142 expect(fixture.getClassName()).toBe(animationClass.up)143 fixture.scrollDown(true)144 expect(fixture.getClassName()).toBe(animationClass.down)145 fixture.scrollDown(false)146 expect(fixture.getClassName()).toBe(animationClass.down)147 })148 test('should toggle appropriate animation regardless of repeat', () => {149 const fixture = createFixture(150 scrollAnimate, { animationClass, repeat: true }151 )152 expect(fixture.getClassName()).toBeFalsy()153 fixture.scrollDown(true)154 expect(fixture.getClassName()).toBe(animationClass.down)155 fixture.scrollDown(false)156 fixture.scrollUp(true)157 expect(fixture.getClassName()).toBe(animationClass.up)158 fixture.scrollUp(false)159 fixture.scrollDown(true)160 expect(fixture.getClassName()).toBe(animationClass.down)161 })162 })163 ...
middlewares.py
Source:middlewares.py
1import websockets2from scrapy.http import HtmlResponse3from logging import getLogger4import asyncio5import pyppeteer6import logging7from concurrent.futures._base import TimeoutError8pyppeteer_level = logging.WARNING9logging.getLogger('websockets.protocol').setLevel(pyppeteer_level)10logging.getLogger('pyppeteer').setLevel(pyppeteer_level)11class PyppeteerMiddleware():12 def __init__(self, **args):13 """14 init logger, loop, browser15 :param args:16 """17 self.logger = getLogger(__name__)18 self.loop = asyncio.get_event_loop()19 self.browser = self.loop.run_until_complete(20 pyppeteer.launch(headless=True))21 self.args = args22 23 def __del__(self):24 """25 close loop26 :return:27 """28 self.loop.close()29 30 def render(self, url, retries=1, script=None, wait=0.3, scrolldown=False, sleep=0,31 timeout=8.0, keep_page=False):32 """33 render page with pyppeteer34 :param url: page url35 :param retries: max retry times36 :param script: js script to evaluate37 :param wait: number of seconds to wait before loading the page, preventing timeouts38 :param scrolldown: how many times to page down39 :param sleep: how many long to sleep after initial render40 :param timeout: the longest wait time, otherwise raise timeout error41 :param keep_page: keep page not to be closed, browser object needed42 :param browser: pyppetter browser object43 :param with_result: return with js evaluation result44 :return: content, [result]45 """46 47 # define async render48 async def async_render(url, script, scrolldown, sleep, wait, timeout, keep_page):49 try:50 # basic render51 page = await self.browser.newPage()52 await asyncio.sleep(wait)53 response = await page.goto(url, options={'timeout': int(timeout * 1000)})54 if response.status != 200:55 return None, None, response.status56 result = None57 # evaluate with script58 if script:59 result = await page.evaluate(script)60 61 # scroll down for {scrolldown} times62 if scrolldown:63 for _ in range(scrolldown):64 await page._keyboard.down('PageDown')65 await asyncio.sleep(sleep)66 else:67 await asyncio.sleep(sleep)68 if scrolldown:69 await page._keyboard.up('PageDown')70 71 # get html of page72 content = await page.content()73 74 return content, result, response.status75 except TimeoutError:76 return None, None, 50077 finally:78 # if keep page, do not close it79 if not keep_page:80 await page.close()81 82 content, result, status = [None] * 383 84 # retry for {retries} times85 for i in range(retries):86 if not content:87 content, result, status = self.loop.run_until_complete(88 async_render(url=url, script=script, sleep=sleep, wait=wait,89 scrolldown=scrolldown, timeout=timeout, keep_page=keep_page))90 else:91 break92 93 # if need to return js evaluation result94 return content, result, status95 96 def process_request(self, request, spider):97 """98 :param request: request object99 :param spider: spider object100 :return: HtmlResponse101 """102 if request.meta.get('render'):103 try:104 self.logger.debug('rendering %s', request.url)105 html, result, status = self.render(request.url)106 return HtmlResponse(url=request.url, body=html, request=request, encoding='utf-8',107 status=status)108 except websockets.exceptions.ConnectionClosed:109 pass110 111 @classmethod112 def from_crawler(cls, crawler):...
sel.py
Source:sel.py
1from selenium import webdriver2from selenium.webdriver.common.keys import Keys3import time, urllib.request4import os5PATH = 6driver = webdriver.Chrome(PATH)7driver.get("https://www.instagram.com/")8# login9time.sleep(5)10username = driver.find_element_by_css_selector("input[name='username']")11password = driver.find_element_by_css_selector("input[name='password']")12username.clear()13password.clear()14username.send_keys("")15password.send_keys("")16login = driver.find_element_by_css_selector("button[type='submit']").click()17# save your login info?18time.sleep(10)19# notnow = driver.find_element_by_xpath("//button[contains(text(), 'Not Now')]").click()20# turn on notif21# time.sleep(10)22# notnow2 = driver.find_element_by_xpath("//button[contains(text(), 'Not Now')]").click()23# searchbox24time.sleep(5)25searchbox = driver.find_element_by_css_selector("input[placeholder='Search']")26searchbox.clear()27searchbox.send_keys("host.py")28time.sleep(5)29searchbox.send_keys(Keys.ENTER)30time.sleep(5)31searchbox.send_keys(Keys.ENTER)32# scroll33scrolldown = driver.execute_script(34 "window.scrollTo(0, document.body.scrollHeight);var scrolldown=document.body.scrollHeight;return scrolldown;")35match = False36while (match == False):37 last_count = scrolldown38 time.sleep(3)39 scrolldown = driver.execute_script(40 "window.scrollTo(0, document.body.scrollHeight);var scrolldown=document.body.scrollHeight;return scrolldown;")41 if last_count == scrolldown:42 match = True43# posts44posts = []45links = driver.find_elements_by_tag_name('a')46for link in links:47 post = link.get_attribute('href')48 if '/p/' in post:49 posts.append(post)50print(posts)51# get videos and images52download_url = ''53for post in posts:54 driver.get(post)55 shortcode = driver.current_url.split("/")[-2]56 time.sleep(7)57 if driver.find_element_by_css_selector("img[style='object-fit: cover;']") is not None:58 download_url = driver.find_element_by_css_selector("img[style='object-fit: cover;']").get_attribute('src')59 urllib.request.urlretrieve(download_url, '{}.jpg'.format(shortcode))60 else:61 download_url = driver.find_element_by_css_selector("video[type='video/mp4']").get_attribute('src')62 urllib.request.urlretrieve(download_url, '{}.mp4'.format(shortcode))...
Using AI Code Generation
1scrollDown(3)2scrollUp(3)3scrollRight(3)4scrollLeft(3)5scrollRight(3)6scrollDown(3)7scrollUp(3)8scrollLeft(3)9scrollRight(3)10scrollDown(3)11scrollUp(3)12scrollLeft(3)13scrollRight(3)14scrollDown(3)15scrollUp(3)16scrollLeft(3)17scrollRight(3)18scrollDown(3)19scrollUp(3)20scrollLeft(3)21scrollRight(3)22scrollDown(3)23scrollUp(3)24scrollLeft(3)25scrollRight(3)26scrollDown(3)27scrollUp(3)28scrollLeft(3)29scrollRight(3)30scrollDown(3)31scrollUp(3)
Using AI Code Generation
1import { scrollDown } from 'taiko';2(async () => {3 await scrollDown(100);4})();5import { scrollUp } from 'taiko';6(async () => {7 await scrollUp(100);8})();9import { scrollTo } from 'taiko';10(async () => {11 await scrollTo(100, 100);12})();13import { scrollRight } from 'taiko';14(async () => {15 await scrollRight(100);16})();17import { scrollLeft } from 'taiko';18(async () => {19 await scrollLeft(100);20})();21import { scrollTo } from 'taiko';22(async () => {23 await scrollTo("text");24})();25import { scrollTo } from 'taiko';26(async () => {27 await scrollTo("text", "text");28})();29import { scrollTo } from 'taiko';30(async () => {31 await scrollTo("text", "text", "text");32})();33import { scrollTo } from 'taiko';34(async () => {35 await scrollTo("text", "text", "text", "text");36})();37import { scrollTo } from 'taiko';38(async () => {39 await scrollTo("text", "text", "text", "text", "text");40})();41import { scrollTo } from 'taiko';42(async () => {43 await scrollTo("text", "text", "text", "text", "text", "text");44})();45import { scrollTo } from 'taiko';46(async () => {47 await scrollTo("text", "text", "text", "text", "text", "text", "text");48})();
Using AI Code Generation
1scrollDown();2scrollDown(5);3scrollDown({x:100,y:100});4scrollDown(5, {x:100,y:100});5scrollUp();6scrollUp(5);7scrollUp({x:100,y:100});8scrollUp(5, {x:100,y:100});9scrollTo(50);10scrollTo(50, {x:100,y:100});11scrollLeft();12scrollLeft(5);13scrollLeft({x:100,y:100});14scrollLeft(5, {x:100,y:100});15scrollRight();16scrollRight(5);17scrollRight({x:100,y:100});18scrollRight(5, {x:100,y:100});19scrollTo("bottom");20scrollTo("top");21scrollTo("left");22scrollTo("right");23scrollTo("bottom", {x:100,y:100});24scrollTo("top", {x:100,y:100});25scrollTo("left", {x:100,y:100});26scrollTo("right", {x:100,y:100});27scrollTo("bottom", 50);28scrollTo("top", 50);29scrollTo("left", 50);30scrollTo("right", 50);31scrollTo("bottom", 50, {x:100,y:100});32scrollTo("top", 50, {x:100,y:100});33scrollTo("left", 50, {x:100,y:100});34scrollTo("right", 50, {x:100,y:100});35scrollRight(50);36scrollRight(50, {x:100,y:100});37scrollLeft(50);38scrollLeft(50, {x:100,y:100});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!