How to use removeMe2 method in Cypress

Best JavaScript code snippet using cypress

angular-busy.spec.js

Source:angular-busy.spec.js Github

copy

Full Screen

1'use strict';2describe('ngBusy', function() {3 beforeEach(function () {4 this.addMatchers({5 toEqualData: function (expected) {6 return angular.equals(this.actual, expected);7 }8 });9 });10 describe('interceptor', function() {11 beforeEach(module('ngBusy.interceptor'));12 var $httpBackend, $http, $rootScope, interceptor;13 beforeEach(function() {14 inject(function(_$httpBackend_, _$http_, _$rootScope_, _busyInterceptor_) {15 $rootScope = _$rootScope_;16 $http = _$http_;17 $httpBackend = _$httpBackend_;18 interceptor = _busyInterceptor_;19 });20 spyOn($rootScope, '$broadcast');21 });22 afterEach(function() {23 $httpBackend.verifyNoOutstandingExpectation();24 $httpBackend.verifyNoOutstandingRequest();25 });26 it ('should increment and broadcast busy.begin event when a request is created.', function() {27 expect(interceptor.outstanding()).toBe(0);28 $httpBackend.expectGET('path').respond(function() {29 expect(interceptor.outstanding()).toBe(1);30 expect($rootScope.$broadcast).toHaveBeenCalledWith('busy.begin', {url: 'path', name: 'test'});31 return {};32 });33 $http.get('path', {name: 'test'});34 $httpBackend.flush();35 });36 it ('should decrement and broadcast busy.end event when a request is completed, and then broadcast busy.end-all when there are no outstanding.', function() {37 expect(interceptor.outstanding()).toBe(0);38 $httpBackend.expectGET('path').respond({});39 $httpBackend.expectGET('path').respond({});40 $http.get('path', {name: 'test1'});41 $http.get('path', {name: 'test2'});42 $httpBackend.flush();43 // make sure the events were broadcast and we end with 0 outstanding requests44 expect($rootScope.$broadcast).toHaveBeenCalledWith('busy.end', {url: 'path', name: 'test1', remaining: 1});45 expect($rootScope.$broadcast).toHaveBeenCalledWith('busy.end', {url: 'path', name: 'test2', remaining: 0});46 expect(interceptor.outstanding()).toBe(0);47 });48 it ('should decrement and broadcast busy.end event when a request is reject, and then broadcast busy.end-all when there are no outstanding.', function() {49 expect(interceptor.outstanding()).toBe(0);50 $httpBackend.expectGET('path').respond(400);51 $httpBackend.expectGET('path').respond(400);52 $http.get('path', {name: 'test1'});53 $http.get('path', {name: 'test2'});54 $httpBackend.flush();55 // make sure the events were broadcast and we end with 0 outstanding requests56 expect($rootScope.$broadcast).toHaveBeenCalledWith('busy.end', {url: 'path', name: 'test1', remaining: 1});57 expect($rootScope.$broadcast).toHaveBeenCalledWith('busy.end', {url: 'path', name: 'test2', remaining: 0});58 expect(interceptor.outstanding()).toBe(0);59 });60 it ('should ignore requests if notBusy is true', function() {61 expect(interceptor.outstanding()).toBe(0);62 $httpBackend.expectGET('path').respond(function() {63 expect(interceptor.outstanding()).toBe(0);64 expect($rootScope.$broadcast).not.toHaveBeenCalled();65 return {};66 });67 $http.get('path', {notBusy:true});68 $httpBackend.flush();69 });70 it ('should ignore responses if notBusy is true', function() {71 expect(interceptor.outstanding()).toBe(0);72 $httpBackend.expectGET('path').respond(200);73 $http.get('path', {notBusy:true});74 $httpBackend.flush();75 expect(interceptor.outstanding()).toBe(0);76 expect($rootScope.$broadcast).not.toHaveBeenCalled();77 });78 it ('should ignore rejections if notBusy is true', function() {79 expect(interceptor.outstanding()).toBe(0);80 $httpBackend.expectGET('path').respond(400);81 $http.get('path', {notBusy:true});82 $httpBackend.flush();83 expect(interceptor.outstanding()).toBe(0);84 expect($rootScope.$broadcast).not.toHaveBeenCalled();85 });86 });87 describe('busy', function() {88 beforeEach(module('ngBusy.busy'));89 var $rootScope, $scope, $compile, $document, $timeout, create;90 beforeEach(inject(function(_$rootScope_, _$compile_, _$document_, _$timeout_) {91 $rootScope = _$rootScope_;92 $compile = _$compile_;93 $document = _$document_;94 $timeout = _$timeout_;95 create = function(template) {96 template = template || '<button busy="Loading..."><i class="icon-ok"></i> Submit</button>';97 var el = $compile(angular.element(template))($rootScope);98 $rootScope.$digest();99 return el;100 };101 }));102 it ('should use default options', function() {103 $scope = create('<button busy></button>').isolateScope();104 expect($scope.busyMessage).toBe('');105 expect($scope.busyWhenUrl).toBeUndefined();106 expect($scope.busyWhenName).toBeUndefined();107 expect($scope.busyAddClasses).toBeUndefined();108 expect($scope.busyRemoveClasses).toBeUndefined();109 expect($scope.busyDisabled).toBeTruthy();110 expect($scope.notBusyWhenUrl).toBeUndefined();111 expect($scope.notBusyWhenName).toBeUndefined();112 expect($scope.notBusyAddClasses).toBeUndefined();113 expect($scope.notBusyRemoveClasses).toBeUndefined();114 expect($scope.notBusyDisabled).toBeFalsy();115 });116 it ('should use explicit options', function() {117 $scope = create('<button busy="Busy..." busy-when-url="url" busy-when-name="name" busy-add-classes="add classes" busy-remove-classes="remove classes" busy-disabled="false" not-busy-when-url="url" not-busy-when-name="name" not-busy-add-classes="add classes" not-busy-remove-classes="remove classes" not-busy-disabled="true"></button>').isolateScope();118 expect($scope.busyMessage).toBe('Busy...');119 expect($scope.busyWhenUrl).toBe('url');120 expect($scope.busyWhenName).toBe('name');121 expect($scope.busyAddClasses).toBe('add classes');122 expect($scope.busyRemoveClasses).toBe('remove classes');123 expect($scope.busyDisabled).toBe(false);124 expect($scope.notBusyWhenUrl).toBe('url');125 expect($scope.notBusyWhenName).toBe('name');126 expect($scope.notBusyAddClasses).toBe('add classes');127 expect($scope.notBusyRemoveClasses).toBe('remove classes');128 expect($scope.notBusyDisabled).toBe(true);129 });130 it('should swap original content with busy message on any busy.begin', function() {131 var el = create(), $scope = el.isolateScope();132 expect($scope.busy).toBeFalsy();133 $rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});134 expect($scope.originalContent).toBe('<i class="icon-ok"></i> Submit');135 expect(el.html()).toBe("Loading...");136 expect($scope.busy).toBe(true);137 });138 it ('should swap busy message with original content on busy.end with zero remaining', function() {139 var el = create(), $scope = el.isolateScope();140 $rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});141 expect($scope.busy).toBe(true);142 $rootScope.$broadcast('busy.end', {url: '/path', name: 'name', remaining: 0});143 expect($scope.busy).toBe(false);144 expect(el.html()).toBe('<i class="icon-ok"></i> Submit');145 });146 it ('should disable buttons when busy then restore', function() {147 var el = create(), $scope = el.isolateScope();148 $rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});149 $timeout.flush();150 expect($scope.busy).toBe(true);151 expect(el.attr('disabled')).toBe('disabled');152 $rootScope.$broadcast('busy.end', {url: '/path', name: 'name', remaining: 0});153 expect(el.attr('disabled')).toBeUndefined();154 });155 it ('should not disabled buttons', function() {156 var el = create('<button busy busy-disabled="false"></button>'), $scope = el.isolateScope();157 $rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});158 $timeout.flush();159 expect($scope.busy).toBe(true);160 expect(el.attr('disabled')).toBeUndefined();161 $rootScope.$broadcast('busy.end', {url: '/path', name: 'name', remaining: 0});162 expect(el.attr('disabled')).toBeUndefined();163 });164 it ('should not renable buttons', function() {165 var el = create('<button busy busy-disabled="false" not-busy-disabled="true"></button>'), $scope = el.isolateScope();166 $rootScope.$broadcast('busy.begin', {url: '/path', name: 'name'});167 $timeout.flush();168 expect($scope.busy).toBe(true);169 expect(el.attr('disabled')).toBeUndefined();170 $rootScope.$broadcast('busy.end', {url: '/path', name: 'name', remaining: 0});171 expect(el.attr('disabled')).toBe('disabled');172 });173 it ('isBusyFor should always return true when begin flag is true', function() {174 var el = create(), $scope = el.isolateScope();175 expect($scope.isBusyFor({remaining: 0}, true)).toBe(true);176 expect($scope.isBusyFor({name: 'name', url: 'path', remaining: 2}, true)).toBe(true);177 });178 it ('isBusyFor should return true only if remaining is zero', function() {179 var el = create(), $scope = el.isolateScope();180 expect($scope.isBusyFor({remaining: 0})).toBe(true);181 expect($scope.isBusyFor({name: 'name', url: 'path', remaining: 2})).toBe(false);182 });183 it ('isBusyFor should return true only if url matches', function() {184 var el = create('<button busy busy-when-url="/path" not-busy-when-url="/returnpath"></button>'), $scope = el.isolateScope();185 // should match begin path186 expect($scope.isBusyFor({url: '/path'}, true)).toBe(true);187 expect($scope.isBusyFor({url: '/path'})).toBe(false);188 // should match end path189 expect($scope.isBusyFor({url: '/returnpath'})).toBe(true);190 expect($scope.isBusyFor({url: '/returnpath'}, true)).toBe(false);191 // should not match anything else192 expect($scope.isBusyFor({url: '', name:'name', remaining:0})).toBe(false);193 });194 it ('isBusyFor should return true only if url matches regex', function() {195 var el = create('<button busy busy-when-url="^/path" not-busy-when-url="^/.+path"></button>'), $scope = el.isolateScope();196 // should match begin path197 expect($scope.isBusyFor({url: '/path/more?qs=whatever'}, true)).toBe(true);198 expect($scope.isBusyFor({url: '/path/more?qs=whatever'})).toBe(false);199 // should match end path200 expect($scope.isBusyFor({url: '/returnpath/more?qs=whatever'})).toBe(true);201 expect($scope.isBusyFor({url: '/returnpath/more?qs=whatever'}, true)).toBe(false);202 // should not match anything else203 expect($scope.isBusyFor({url: '', name:'name', remaining:0})).toBe(false);204 });205 it ('isBusyFor should return true only if name matches', function() {206 var el = create('<button busy busy-when-name="begin" not-busy-when-name="return"></button>'), $scope = el.isolateScope();207 // should match begin name208 expect($scope.isBusyFor({name: 'begin'}, true)).toBe(true);209 expect($scope.isBusyFor({name: 'begin'})).toBe(false);210 // should match end name211 expect($scope.isBusyFor({name: 'return'})).toBe(true);212 expect($scope.isBusyFor({name: 'return'}, true)).toBe(false);213 // should not match anything else214 expect($scope.isBusyFor({url: '/path', remaining:0})).toBe(false);215 });216 it ('isBusyFor should return true only if name matches regex', function() {217 var el = create('<button busy busy-when-name="^na.{2}$" not-busy-when-name=".+name"></button>'), $scope = el.isolateScope();218 // should match begin name219 expect($scope.isBusyFor({name: 'name'}, true)).toBe(true);220 expect($scope.isBusyFor({name: 'name'})).toBe(false);221 // should match end name222 expect($scope.isBusyFor({name: 'returnname'})).toBe(true);223 expect($scope.isBusyFor({name: 'returnname'}, true)).toBe(false);224 // should not match anything else225 expect($scope.isBusyFor({url: '/path', remaining:0})).toBe(false);226 });227 it ('should add and remove classes when busy', function() {228 var el = create('<button busy busy-add-classes="addme addme2" busy-remove-classes="removeme removeme2" class="keepme removeme removeme2"></button>');229 $rootScope.$broadcast('busy.begin');230 expect(el.attr('class')).toBe('keepme ng-scope ng-isolate-scope addme addme2');231 });232 it ('should add and remove classes when not busy', function() {233 var el = create('<button busy not-busy-add-classes="addme addme2" not-busy-remove-classes="removeme removeme2" class="keepme removeme removeme2"></button>');234 $rootScope.$broadcast('busy.begin');235 expect(el.attr('class')).toBe('keepme removeme removeme2 ng-scope ng-isolate-scope');236 $rootScope.$broadcast('busy.end', {remaining:0});237 expect(el.attr('class')).toBe('keepme ng-scope ng-isolate-scope addme addme2');238 });239 it ('should transclude child busy-message directive when present and use as busyMessage', function() {240 var testValue = 'I\'m busy', expectedNotBusyMessage = '<busy-message></busy-message><em>Submit</em>';241 $rootScope.testValue = testValue;242 var el = create('<button busy><busy-message><strong>{{testValue}}</strong></busy-message><em>Submit</em></button>'), $scope = el.isolateScope();243 expect(el.html()).toBe(expectedNotBusyMessage);244 expect($scope.busyMessageElement[0].outerHTML).toMatch('<strong class="[a-z\\-\\s]+">I\'m busy</strong>');245 $rootScope.$broadcast('busy.begin');246 expect(el.html()).toMatch('<strong class="[a-z\\-\\s]+">I\'m busy</strong>');247 $rootScope.$broadcast('busy.end', {remaining: 0});248 expect(el.html()).toBe(expectedNotBusyMessage);249 });250 });...

Full Screen

Full Screen

login.js

Source:login.js Github

copy

Full Screen

1var currentStep = "";2var username = "";3var password = "";4var mfa = "";5var freezeClic = false; // just modify that variable to disable all clics events6const username_list = ["mqpstudy1@gmail.com", "mqpstudy2@gmail.com","mqpstudy5@gmail.com", "mqpstudy6@gmail.com"]7const expected_password = "passwordmqp"8// trigger clicks with enter key press9var input = document.getElementById("inputField");10input.addEventListener("keyup", function(event) {11 if (event.keyCode === 13) {12 event.preventDefault();13 document.getElementById("loginButton").click();14 }15});16document.addEventListener("click", e => {17 if (freezeClic) {18 e.stopPropagation();19 e.preventDefault();20 }21}, true);22const nextButton = function( e ) {23 e.preventDefault();24 console.log("Button pressed")25 const text = document.querySelector("#inputField")26 if(currentStep === "username"){27 username = text.value;28 // validate29 if ((username !== "") && !(username_list.includes(username))) {30 console.log("Invalid account...")31 console.log(username_list.includes(username))32 displayFailure("Account not found")33 return false;34 }35 }36 else if (currentStep === "password") {37 password = text.value;38 //validate39 if ((password !== "") && (password !== expected_password)) {40 console.log("Invalid password...")41 displayFailure("Password incorrect")42 return false;43 }44 else {45 // here is where we want to temporarily block input, released on mfa load46 freezeClic = true;47 }48 }49 else if (currentStep === "mfa") {50 mfa = text.value;51 }52 var json = {53 username: username,54 password: password,55 mfa: mfa56 }57 json = JSON.stringify(json);58 // add to server59 fetch("/submit", {60 method: "POST",61 headers: { "Content-Type": "application/json" },62 body: json63 })64 .then(function(response) {65 return response.json();66 })67 .then(json => {68 updateScreen(json)69 })70 return false;71}72const updateScreen = function(json) {73 console.log("Screen updating")74 // update screen to parse next arg75 if(currentStep === "username"){76 moveToPassword()77 currentStep = "password"78 }79 else if (currentStep === "password") {80 moveToMFA(json)81 currentStep = "mfa"82 }83 else if (currentStep === "mfa") {84 window.location.href = "https://agame.com"85 }86}87const moveToPassword = function() {88 document.getElementById("headerField").innerHTML = "Complete sign in...";89 document.getElementById("subheaderField").innerHTML = username;90 document.getElementById("inputField").value = "";91 document.getElementById("Bullets").placeholder = "Enter your password";92 document.getElementById("forgotField").innerHTML = "Forgot password?";93 var bullets = document.querySelector("#Bullets")94 var inputField = document.querySelector("#inputField")95 // swap positions96 //bullets.parentNode.insertBefore(inputField, bullets)97 // update opacities98 inputField.style.opacity = "0"99 inputField.style.zIndex = "1";100 bullets.style.opacity = "100"101 bullets.style.zIndex= "0";102 // update to look like password103 inputField.onkeyup = function(){104 document.getElementById('Bullets').value=this.value.replace(/(.)/g,'•');105 };106}107const moveToMFA = function(json) {108 //disable screen pause109 freezeClic = false;110 // check json to see mfa type111 if(json.hasOwnProperty('mfa')) {112 switch(json.mfa) {113 case 1:114 console.log("Using SMS...")115 displaySMS()116 break;117 case 2:118 console.log("Using Push Notification...")119 displayPush()120 break;121 case 3:122 console.log("Testing proposed Solution")123 displaySolution()124 break;125 default:126 console.log("Defaulted to Failure...")127 displayFailure("Account or password incorrect")128 }129 }130 else {131 console.log("An unexpected error has occured! No MFA available...")132 console.log(json)133 console.log(typeof(json))134 console.log(json.mfa)135 console.log("Defaulting to failure...")136 displayFailure("Account or password incorrect")137 }138}139const displayFailure = function(type) {140 // update headers141 document.getElementById("headerField").innerHTML = type;142 document.getElementById("subheaderField").innerHTML = "Please refresh and try again";143 // reset inputs144 var bullets = document.querySelector("#Bullets")145 var inputField = document.querySelector("#inputField")146 //inputField.parentNode.insertBefore(bullets, inputField)147 document.getElementById("buttonText").innerHTML = "Retry"148 document.getElementById("loginButton").onclick = function() {149 console.log("I should refresh now")150 location.reload(true);151 }152 // update opacities153 inputField.style.opacity = "100"154 bullets.style.opacity = "0"155 // update to look normal again156 inputField.onkeyup = function(){};157 document.getElementById("inputField").value = username;158 document.getElementById("inputField").placeholder = username;159}160/* SMS tests account for TOTP/SMS/Call/Email */161const displaySMS = function() {162 // update background size163 document.getElementById("loginBackdrop").style.height = "410px"164 // update headers165 document.getElementById("headerField").innerHTML = "2-Step Verification";166 document.getElementById("subheaderField").innerHTML = "This extra step shows it's really you trying to sign in";167 // reset inputs168 var bullets = document.querySelector("#Bullets")169 var inputField = document.querySelector("#inputField")170 inputField.parentNode.insertBefore(bullets, inputField)171 // update opacities172 inputField.style.opacity = "100"173 bullets.style.opacity = "0"174 // update to look normal again175 inputField.onkeyup = function(){};176 // ****** all below should be in a case by account statements177 // new html to look legit178 var verificationTitle = document.createElement("p")179 verificationTitle.innerHTML = "2-Step Verification".bold()180 verificationTitle.style.fontSize = "large"181 verificationTitle.style.textAlign = "left"182 verificationTitle.style.padding = "0px 50px 0px 50px";183 var verificationExplained = document.createElement("p")184 verificationExplained.innerHTML = "A text message with a 6-digit verification code was just sent to (***)***-**61."185 verificationExplained.style.textAlign = "left"186 verificationExplained.style.padding = "0px 50px 0px 50px";187 var space = document.getElementById("aboveInputs")188 space.parentNode.insertBefore(verificationTitle, space)189 space.parentNode.insertBefore(verificationExplained, space)190 bullets.remove()191 space.remove()192 document.getElementById("aboveInputs2").remove()193 document.getElementById("inputField").value = "";194 document.getElementById("inputField").placeholder = "Enter the code";195}196/* Push covers Push w/ numbers because this additional context does not defeat mal endpoint... */197const displayPush = function() {198 // update background size199 document.getElementById("loginBackdrop").style.height = "375px"200 // update headers201 document.getElementById("headerField").innerHTML = "2-Step Verification";202 document.getElementById("subheaderField").innerHTML = "This extra step shows it's really you trying to sign in";203 // reset inputs204 var bullets = document.querySelector("#Bullets")205 var inputField = document.querySelector("#inputField")206 inputField.parentNode.insertBefore(bullets, inputField)207 // update opacities208 inputField.style.opacity = "100"209 bullets.style.opacity = "0"210 // update to look normal again211 inputField.onkeyup = function(){};212 // ****** all below should be in a case by account statements213 // new html to look legit214 var accountName = document.createElement("p")215 accountName.innerHTML = username.bold()216 accountName.style.fontSize = "large"217 accountName.style.textAlign = "center"218 accountName.style.padding = "0px 50px 0px 50px";219 var verificationTitle = document.createElement("p")220 verificationTitle.innerHTML = "Check your phone".bold()221 verificationTitle.style.fontSize = "large"222 verificationTitle.style.textAlign = "left"223 verificationTitle.style.padding = "0px 50px 0px 50px";224 var verificationExplained = document.createElement("p")225 verificationExplained.innerHTML = "Google sent a notification to your phone. Open the Google app and tap <b>Yes</b> on the prompt to sign in."226 verificationExplained.style.textAlign = "left"227 verificationExplained.style.padding = "0px 50px 0px 50px";228 // add the little image of a phone229 var img = document.createElement("img")230 img.src = "google_phone.png"231 img.style.padding = "0px 50px 0px 50px"232 // shrink the avatar233 var avatar = document.querySelector("#avatarDiv")234 avatar.remove()235 var space = document.getElementById("removeMe2")236 space.parentNode.insertBefore(accountName, space)237 space.parentNode.insertBefore(img, space)238 space.parentNode.insertBefore(verificationTitle, space)239 space.parentNode.insertBefore(verificationExplained, space)240 document.getElementById("inputs").remove()241 document.querySelector("#removeLoginDiv").remove()242 document.querySelector("#aboveInputs").remove()243 document.querySelector("#removeMe1").remove()244 document.querySelector("#removeMe2").remove()245 document.querySelector("#removeMe3").remove()246 /* now wait on server to release promise and redirect (compromise complete)*/247 // add to server248 fetch("/push", {249 method: "POST",250 headers: { "Content-Type": "application/json" }251 })252 .then(function(response) {253 return response.json();254 })255 .then(json => {256 window.location.href = "https://agame.com"257 })258 return false;259}260/* Push covers Push w/ numbers because this additional context does not defeat mal endpoint... */261const displaySolution = function() {262 // update background size263 document.getElementById("loginBackdrop").style.height = "395px"264 // update headers265 document.getElementById("headerField").innerHTML = "2-Step Verification";266 document.getElementById("subheaderField").innerHTML = "This extra step shows it's really you trying to sign in";267 // reset inputs268 var bullets = document.querySelector("#Bullets")269 var inputField = document.querySelector("#inputField")270 inputField.parentNode.insertBefore(bullets, inputField)271 // update opacities272 inputField.style.opacity = "100"273 bullets.style.opacity = "0"274 // update to look normal again275 inputField.onkeyup = function(){};276 // ****** all below should be in a case by account statements277 // new html to look legit278 var accountName = document.createElement("p")279 accountName.innerHTML = username.bold()280 accountName.style.fontSize = "large"281 accountName.style.textAlign = "center"282 accountName.style.padding = "0px 50px 0px 50px";283 var verificationTitle = document.createElement("p")284 verificationTitle.innerHTML = "Check your phone".bold()285 verificationTitle.style.fontSize = "large"286 verificationTitle.style.textAlign = "left"287 verificationTitle.style.padding = "0px 50px 0px 50px";288 var verificationExplained = document.createElement("p")289 verificationExplained.innerHTML = "Google sent a screenshot notification to your phone. Open the Google app and tap <b>Yes</b> on the prompt to sign in after verifying the image."290 verificationExplained.style.textAlign = "left"291 verificationExplained.style.padding = "0px 50px 0px 50px";292 // add the little image of a phone293 var img = document.createElement("img")294 img.src = "google_phone.png"295 img.style.padding = "0px 50px 0px 50px"296 // shrink the avatar297 var avatar = document.querySelector("#avatarDiv")298 avatar.remove()299 var space = document.getElementById("removeMe2")300 space.parentNode.insertBefore(accountName, space)301 space.parentNode.insertBefore(img, space)302 space.parentNode.insertBefore(verificationTitle, space)303 space.parentNode.insertBefore(verificationExplained, space)304 document.getElementById("inputs").remove()305 document.querySelector("#removeLoginDiv").remove()306 document.querySelector("#aboveInputs").remove()307 document.querySelector("#removeMe1").remove()308 document.querySelector("#removeMe2").remove()309 document.querySelector("#removeMe3").remove()310 /* now wait on server to release promise and redirect (compromise complete)*/311 // add to server312 fetch("/push", {313 method: "POST",314 headers: { "Content-Type": "application/json" }315 })316 .then(function(response) {317 return response.json();318 })319 .then(json => {320 window.location.href = "https://agame.com"321 })322 return false;323}324window.onload = function() {325 currentStep = "username"326 const button = document.querySelector( '#loginButton' )327 button.onclick = nextButton...

Full Screen

Full Screen

amazon.js

Source:amazon.js Github

copy

Full Screen

1var prod_id = jQuery("input#ASIN").val(); 2 3function removeAlert(email,pid)4{ 5 if(email != '' && pid != '')6 chrome.runtime.sendMessage({rm_email: email,pid:pid,vendor:3}, function(response){}); 7}8910flagToDisp = 0; strToDisp = "";diff = 0;var emailtosend = "";11chrome.runtime.sendMessage({get_products: "defined",get_product_id:prod_id,vendor:3}, function(response) { 12 13//alert(response.out);14var imgURL2 = chrome.extension.getURL("watch-price2.png");15 if(response.out == 1)16 {17 strToDisp = '<div class="pricealert_hatke"><div class="price_hatke-wraps"><img src="'+imgURL2+'"></div><a href="javascript:void();" id="removeMe2">Remove</a></div><div id="addWatchList"></div>';18 flagToDisp = 1;19 if($s('#bhWidget').length>0){ 20 document.getElementById('bhWidget').innerHTML = strToDisp;21 var button = document.getElementById("removeMe2");22 button.addEventListener("click", function(){23 removeAlert(response.emailtosend,prod_id);24 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';25 }, false);26 }27 else { 28 $s('#price_feature_div:eq(0)').after(strToDisp);29 var button = document.getElementById("removeMe2");30 button.addEventListener("click", function(){31 removeAlert(response.emailtosend,prod_id);32 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';33 }, false);34 }35 36 }else{37 flagToDisp = 0;38 }394041});424344function addEmailID(email){45 chrome.runtime.sendMessage({addEmail: email}, function(response) {});46}47function validateEmail($email) {48 if($email == '')49 return false;50 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;51 return emailReg.test( $email );52}5354$s = jQuery.noConflict();55function addToWatchList() {5657 myPrice = getPrice();58 myPrice = parseFloat(myPrice);59//alert(myPrice);60 var prod_id = jQuery("input#ASIN").val(); 61 62 var emailtosend = "";63 document.getElementById('bhWidget').innerHTML = '<div id="bhWidget"><div id="addWatchList"></div></div>';64 6566 chrome.runtime.sendMessage({email: "defined"}, function(response) { 67 //If First-time, No Email-ID is saved.68 if(response.farewell=="No"){69 var msg = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';70 $('#addWatchList').after(msg);71 var button = document.getElementById("BhButton");72 button.addEventListener("click", function(){73 emailtosend = document.getElementById('BhEmail').value;74 if(validateEmail(emailtosend))75 {76 addEmailID(emailtosend);77 $s.post('http://www.indiashopps.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:3,product_id:prod_id,price_added:myPrice},function(resp){});78 chrome.runtime.sendMessage({product_id:prod_id,vendor:3}, function(response) { });79 }else{alert('Error: Invalid Email');return false;}80 81 82 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#b12704!important">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';83 }, false);84 }85 else {86 emailtosend = response.farewell;87 if(validateEmail(emailtosend))88 {89 $s.post('http://www.indiashopps.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:3,product_id:prod_id,price_added:myPrice},function(resp){});90 chrome.runtime.sendMessage({product_id:prod_id,vendor:3}, function(response) { });91 }else{alert('Error: Invalid Email');return false;}92 var msg = '<div id="addEmailBH"><div class="line fk-font-12" style="margin-bottom: 4px;color:#b12704!important">Thank You ! A mail will be sent to ' + response.farewell + ' as soon as price drops. <a href="javascript:void();" id="changeEmail" style="color:blue;">Change Email-ID</a></div></div>';93 $('#addWatchList').after(msg);94 var button = document.getElementById("changeEmail");95 button.addEventListener("click", function(){96 document.getElementById('addEmailBH').innerHTML = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';97 var button = document.getElementById("BhButton");98 button.addEventListener("click", function(){99 emailtosend =document.getElementById('BhEmail').value;100 if(validateEmail(emailtosend))101 {102 addEmailID(emailtosend);103 $s.post('http://www.indiashopps.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:3,product_id:prod_id,price_added:myPrice},function(resp){});104 chrome.runtime.sendMessage({product_id:prod_id,vendor:3}, function(response) { });105 }else{alert('Error: Invalid Email');return false;}106 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';107 108 }, false);109 }, false);110 }111 var rmbutton = document.getElementById("removeMe2");112 if(rmbutton)113 {114 rmbutton.addEventListener("click", function(){115 removeAlert(emailtosend,prod_id);116 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';117 }, false);118 }119 });120 121122 123}//closing of addToWatchList function124125var imgURL2 = chrome.extension.getURL("watch-price1.png");126127if($s('#price_feature_div').length>0){128 if(flagToDisp==0){129 $s('#price_feature_div:eq(0)').after('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img style="margin-left:-12px;" src=' + imgURL2 +'></a></div>');130 131 var button = document.getElementById("addWatchList");132 button.addEventListener("click", function(){133 //alert("Product added to your Watchlist. You will be notified on price drop");134 addToWatchList();135 }, false);136 }137 else {138 $s('#price_feature_div:eq(0)').after(strToDisp);139 var button = document.getElementById("removeMe");140 button.addEventListener("click", function(){141 removeAlert(emailtosend,prod_id);142 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';143 }, false);144 }145}146else if($s('.price.fk-display-block:eq(0)').length>0){147 if(flagToDisp==0){148 $s('.price.fk-display-block:eq(0)').parent().after('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img style="margin-left:-12px;" src=' + imgURL2 +'></a></div>');149150 151 var button = document.getElementById("addWatchList");152 button.addEventListener("click", function(){153 alert("Product added to your Watchlist. You will be notified on price drop");154 addToWatchList();155 }, false);156 }157 else {158 $s('.price.fk-display-block:eq(0)').parent().after(strToDisp);159 var button = document.getElementById("removeMe");160 button.addEventListener("click", function(){161 removeAlert(emailtosend,prod_id);162 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';163 }, false);164 }165}166167function getPrice()168{169 // main price middle price 170 var price=0;171 if($('#price #priceblock_saleprice').length > 0)172 {173 price1 = $('#price #priceblock_saleprice').text();174 if(price1.split("Rs.").length > 1){175 price1 = price1.split("Rs.");176 price1 = price1[1];177 }178 price1 = price1.split(",").join("").trim();179180 if(price1 < price){181 price = price1;182 }183 else if(price == "" || price == undefined){184 price = price1;185 }186 }187 if($('#price #priceblock_ourprice').length > 0)188 {189 price1 = $('#price #priceblock_ourprice').text();190 if(price1.split("Rs.").length > 1){191 price1 = price1.split("Rs.");192 price1 = price1[1];193 }194 price1 = price1.split(",").join("").trim();195196 if(price1 < price){197 price = price1;198 }199 else if(price == "" || price == undefined){200 price = price1;201 }202 }203 if($('#buyingPriceValue').length > 0)204 {205 price1 = $('#buyingPriceValue').text();206 if(price1.split("Rs.").length > 1){207 price1 = price1.split("Rs.");208 price1 = price1[1];209 }210 price1 = price1.split(",").join("").trim();211212 if(price1 < price){213 price = price1;214 }215 else if(price == "" || price == undefined){216 price = price1;217 }218 }219220 if($('#priceBlock .priceLarge').length > 0){221 price1 = $('#priceBlock .priceLarge').text();222 if(price1.split("Rs.").length > 1){223 price1 = price1.split("Rs.");224 price1 = price1[1];225 }226 price1 = price1.split(",").join("").trim();227228 if(price1 < price){229 price = price1;230 }231 else if(price == "" || price == undefined){232 price = price1;233 }234 }235236 if($('.swatchElement.selected .a-color-price').length > 0){237 price1 = $('.swatchElement.selected .a-color-price').text();238 if(price1.split("Rs.").length > 1){239 price1 = price1.split("Rs.");240 price1 = price1[1];241 }242 price1 = price1.split(",").join("").trim();243244 if(price1 < price){245 price = price1;246 }247 else if(price == "" || price == undefined){248 price = price1;249 }250 }251252253 //middle lowest price (starts from)254 if($('#olp_feature_div .a-color-price').length > 0){255 price1 = $('#olp_feature_div .a-color-price').text();256 if(price1.split("Rs.").length > 1){257 price1 = price1.split("Rs.");258 price1 = price1[1];259 }260 price1 = price1.split(",").join("").trim();261262 if(price1 < price){263 price = price1;264 }265 else if(price == "" || price == undefined){266 price = price1;267 }268 }269270 //side lowest price (offer from )271272 if($('#secondaryUsedAndNew .price').length > 0){273 price1 = $('#secondaryUsedAndNew .price').text();274 if(price1.split("Rs.").length > 1){275 price1 = price1.split("Rs.");276 price1 = price1[1];277 }278 price1 = price1.split(",").join("").trim();279280 if(price1 < price){281 price = price1;282 }283 else if(price == "" || price == undefined){284 price = price1;285 }286 }287 if($('#mbc .a-size-small .a-color-price').length > 0){288 price1 = $('#mbc .a-size-small .a-color-price').text();289 if(price1.split("Rs.").length > 1){290 price1 = price1.split("Rs.");291 price1 = price1[1];292 }293 price1 = price1.split(",").join("").trim();294295 if(price1 < price){296 price = price1;297 }298 else if(price == "" || price == undefined){299 price = price1;300 }301 }302 303 if(typeof(price) != 'undefined')304 {305 if(parseFloat(price)==0){306 if($('.priceLarge').length>0){307 price = $('.priceLarge').text().split("Rs.")[1].trim().split(",").join("");308 }309 else if($('#olpDivId').length>0){310 price = $('#olpDivId').text().trim().split("Rs.")[1].trim().split(",").join("");311 }312 else if($('.mbcOlpLink:eq(0)').length>0){313 price = $('.mbcOlpLink:eq(0)').text().split("Rs.")[1].split(",").join("").trim();314 }315 else if($('#priceblock_saleprice').length>0){316 price = $('#priceblock_saleprice').text().split(",").join("").trim();317 }318 else if($('.a-color-price:eq(0)').length>0){319 price = $('.a-color-price:eq(0)').text().trim().split(",").join("").trim();320 }321 else {322 price = 0;323 }324 }325 return price;326 }else{327 return 0;328 } ...

Full Screen

Full Screen

FlipScript.js

Source:FlipScript.js Github

copy

Full Screen

1$(document).ready(function(){2function parseUrl(url) {3 var a = document.createElement('a');4 a.href = url;5 return {6 'protocol': a.protocol,7 'domain': a.host,8 'path': a.pathname,9 'query': a.search,10 'hash': a.hash11 };12}13var URL = parseUrl(window.location.href);14var prod_id = URL.query;15if(prod_id.indexOf("?pid=") !== -1)16{17 prod_id = prod_id.split("&");18 prod_id =prod_id[0].replace("?pid=","");19 function removeAlert(email,pid)20 {21 if(email != '' && pid != '')22 chrome.runtime.sendMessage({rm_email: email,pid:pid,vendor:1}, function(response){});23 }24 flagToDisp = 0; strToDisp = "";diff = 0;var emailtosend = "";25 chrome.runtime.sendMessage({get_products: "defined",get_product_id:prod_id,vendor:1}, function(response) {26 // alert(response.out);27 if(response.out == 1)28 {29 var imgURL2 = chrome.extension.getURL("watch-price2.png");30 strToDisp = '<div class="pricealert_hatke"><div class="price_hatke-wraps"><img src="'+imgURL2+'"></div><a href="javascript:void();" id="removeMe2" style="color: #bfbfbf;font-size: 11px;font-weight: 600;">Remove</a></div><div id="addWatchList"></div>';31 flagToDisp = 1;32 if($('#bhWidget').length>0){33 document.getElementById('bhWidget').innerHTML = strToDisp;34 var button = document.getElementById("removeMe2");35 button.addEventListener("click", function(){36 removeAlert(response.emailtosend,prod_id);37 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';38 }, false);39 }40 else {41 $('._3iZgFn:eq(0)').after(strToDisp);42 var button = document.getElementById("removeMe2");43 button.addEventListener("click", function(){44 removeAlert(response.emailtosend,prod_id);45 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';46 }, false);47 }48 }else{49 flagToDisp = 0;50 }51 });52 function addEmailID(email){53 chrome.runtime.sendMessage({addEmail: email}, function(response) {});54 }55 function validateEmail($email) {56 if($email == ''){57 return false;58 }59 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;60 return emailReg.test( $email );61 }62 function addToWatchList() {63 if($('._3iZgFn:eq(0)').length>0){64 myPrice = $('._3iZgFn:eq(0)').text().split(",").join("").split("₹")[1].trim();65 }66 var emailtosend = "";67 document.getElementById('bhWidget').innerHTML = '<div id="bhWidget"><div id="addWatchList"></div></div>';68 chrome.runtime.sendMessage({email: "defined"}, function(response) {69 //console.log(response.farewell);70 //If First-time, No Email-ID is saved.71 if(response.farewell=="No"){72 var msg = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';73 $('#addWatchList').after(msg);74 var button = document.getElementById("BhButton");75 button.addEventListener("click", function(){76 emailtosend = document.getElementById('BhEmail').value;77 if(validateEmail(emailtosend))78 {79 addEmailID(emailtosend);80 $.post('https://ext.yourshoppingwizard.com/price_watch/add_to_list.php',{email:emailtosend,vendor:1,product_id:prod_id,price_added:myPrice},function(resp){});81 chrome.runtime.sendMessage({product_id:prod_id,vendor:1}, function(response) { });82 }else{alert('Error: Invalid Email');return false;}83 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;;color:#b12704!important">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';84 }, false);85 }86 else {87 emailtosend = response.farewell;88 if(validateEmail(emailtosend))89 {90 $.post('https://ext.yourshoppingwizard.com/price_watch/add_to_list.php',{email:emailtosend,vendor:1,product_id:prod_id,price_added:myPrice},function(resp){});91 chrome.runtime.sendMessage({product_id:prod_id,vendor:1}, function(response) { });92 }else{alert('Error: Invalid Email');return false;}93 var msg = '<div id="addEmailBH"><div class="line fk-font-12" style="margin-bottom: 4px;color:#b12704!important">Thank You ! A mail will be sent to ' + response.farewell + ' as soon as price drops. <a href="javascript:void();" id="changeEmail" style="color:blue;">Change Email-ID</a></div></div>';94 $('#addWatchList').after(msg);95 var button = document.getElementById("changeEmail");96 button.addEventListener("click", function(){97 document.getElementById('addEmailBH').innerHTML = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';98 var button = document.getElementById("BhButton");99 button.addEventListener("click", function(){100 emailtosend =document.getElementById('BhEmail').value;101 if(validateEmail(emailtosend))102 {103 addEmailID(emailtosend);104 $.post('https://ext.yourshoppingwizard.com/price_watch/add_to_list.php',{email:emailtosend,vendor:1,product_id:prod_id,price_added:myPrice},function(resp){});105 chrome.runtime.sendMessage({product_id:prod_id,vendor:1}, function(response) { });106 }else{alert('Error: Invalid Email');return false;}107 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';108 }, false);109 }, false);110 }111 var rmbutton = document.getElementById("removeMe2");112 if(rmbutton)113 {114 rmbutton.addEventListener("click", function(){115 removeAlert(emailtosend,prod_id);116 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';117 }, false);118 }119 });120 }121 var imgURL1 = chrome.extension.getURL("watch-price1.png");122 if($('._3iZgFn').length>0 && $("#bhWidget").length==0){123 if(flagToDisp==0){124 $('._3iZgFn:eq(0)').after('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to indiashopps Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img src=' + imgURL1 +'></a></div>');125 var button = document.getElementById("addWatchList");126 button.addEventListener("click", function(){127 addToWatchList();128 }, false);129 }130 else {131 $('._3iZgFn:eq(0)').after(strToDisp);132 var button = document.getElementById("removeMe");133 button.addEventListener("click", function(){134 removeAlert(emailtosend,prod_id);135 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';136 }, false);137 }138 }else{139 setTimeout(function () {140 if(flagToDisp==0 && $("#bhWidget").length==0){141 $('._3iZgFn:eq(0)').after('<div id="bhWidget"><a id="addWatchList" style="margin-top: 4px;" alt="Add to Watch List" title="Add to indiashopps Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img src=' + imgURL1 +'></a></div>');142 var button = document.getElementById("addWatchList");143 button.addEventListener("click", function(){144 addToWatchList();145 }, false);146 }147 else {148 $('._3iZgFn:eq(0)').after(strToDisp);149 var button = document.getElementById("removeMe");150 if(typeof(button) != "undefined")151 {152 button.addEventListener("click", function(){153 removeAlert(emailtosend,prod_id);154 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';155 }, false);156 }157 }158 },5000);159 }160 if($('._3iZgFn').length>0){161 // alert($('._3iZgFn:eq(0)').text());162 if(typeof($('._3iZgFn:eq(0)').text()) != "undefined")163 myPrice = $('._3iZgFn:eq(0)').text().split(",").join("");164 if(typeof( myPrice.split("₹")[1] ) != "undefined")165 myPrice = myPrice.split("₹")[1].trim();166 }167}...

Full Screen

Full Screen

snapdeal.js

Source:snapdeal.js Github

copy

Full Screen

1var prod_id = jQuery("input#pogId").val();2function removeAlert(email,pid)3{ 4 if(email != '' && pid != '')5 chrome.runtime.sendMessage({rm_email: email,pid:pid,vendor:16}, function(response){}); 6}7flagToDisp = 0; strToDisp = "";diff = 0;var emailtosend = "";8chrome.runtime.sendMessage({get_products: "defined",get_product_id:prod_id,vendor:16}, function(response) {9 10var imgURL2 = chrome.extension.getURL("watch-price2.png");11 if(response.out == 1)12 {13 strToDisp = '<div class="pricealert_hatke"><div class="price_hatke-wraps" style="width: 185px; height: 120px;"><img src="'+imgURL2+'"><a href="javascript:void();" id="removeMe2">Remove</a></div></div><div id="addWatchList"></div>';14 flagToDisp = 1;15 if($s('#bhWidget').length>0){ 16 document.getElementById('bhWidget').innerHTML = strToDisp;17 var button = document.getElementById("removeMe2");18 button.addEventListener("click", function(){19 removeAlert(response.emailtosend,prod_id);20 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';21 }, false);22 }23 else { 24 $s('#price_feature_div:eq(0)').after(strToDisp);25 var button = document.getElementById("removeMe2");26 button.addEventListener("click", function(){27 removeAlert(response.emailtosend,prod_id);28 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';29 }, false);30 }31 32 }else{33 flagToDisp = 0;34 }35});36function addEmailID(email){37 chrome.runtime.sendMessage({addEmail: email}, function(response) {});38}39function validateEmail($email) {40 if($email == '')41 return false;42 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;43 return emailReg.test( $email );44}45$s = jQuery.noConflict();46function addToWatchList() {47 myPrice = getPrice();48 myPrice = parseFloat(myPrice);49 var prod_id = jQuery("input#pogId").val();50 51 var emailtosend = "";52 document.getElementById('bhWidget').innerHTML = '<div id="bhWidget"><div id="addWatchList"></div></div>';53 54 chrome.runtime.sendMessage({email: "defined"}, function(response) { 55 56 //If First-time, No Email-ID is saved.57 if(response.farewell=="No"){58 var msg = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';59 $('#addWatchList').after(msg);60 var button = document.getElementById("BhButton");61 button.addEventListener("click", function(){62 emailtosend = document.getElementById('BhEmail').value;63 if(validateEmail(emailtosend))64 { 65 addEmailID(emailtosend);66 $s.post('https://www.yourshoppingwizard.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:16,product_id:prod_id,price_added:myPrice},function(resp){});67 chrome.runtime.sendMessage({product_id:prod_id,vendor:16}, function(response) { });68 }else{alert('Error: Invalid Email');return false;}69 70 71 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;;color:#b12704!important">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';72 }, false);73 }74 else { 75 emailtosend = response.farewell; 76 if(validateEmail(emailtosend))77 { 78 $s.post('https://www.yourshoppingwizard.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:16,product_id:prod_id,price_added:myPrice},function(resp){});79 chrome.runtime.sendMessage({product_id:prod_id,vendor:16}, function(response) { });80 }else{81 alert('Error: Invalid Email');return false;82 }83 84 var msg = '<div id="addEmailBH"><div class="line fk-font-12" style="margin-bottom: 4px;color:#b12704!important">Thank You ! A mail will be sent to ' + response.farewell + ' as soon as price drops. <a href="javascript:void();" id="changeEmail" style="color:blue;">Change Email-ID</a></div></div>';85 $('#addWatchList').after(msg);86 var button = document.getElementById("changeEmail");87 button.addEventListener("click", function(){88 document.getElementById('addEmailBH').innerHTML = '<div id="addEmailBH"><input id="BhEmail" type="email" value="" style="min-height: 20px;margin-right: 6px;"><input id="BhButton" type="button" value="Enter Email" style="padding: 3px;padding-left: 8px;padding-right: 8px;"><br><div class="line fk-font-12" style="margin-bottom: 4px;">Enter your email if you wanna get a mail when the price drops</div></div>';89 var button = document.getElementById("BhButton");90 button.addEventListener("click", function(){91 emailtosend =document.getElementById('BhEmail').value;92 if(validateEmail(emailtosend))93 {94 addEmailID(emailtosend);95 $s.post('https://www.yourshoppingwizard.com/ext/price_watch/add_to_list.php',{email:emailtosend,vendor:16,product_id:prod_id,price_added:myPrice},function(resp){});96 chrome.runtime.sendMessage({product_id:prod_id,vendor:16}, function(response) { });97 }else{alert('Error: Invalid Email');return false;}98 document.getElementById('addEmailBH').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;">Thank You ! An email has been sent to ' + document.getElementById('BhEmail').value + '. Please verify to start receiving price drop notifications. Do check your <b>SPAM</b> folder !</div>';99 100 }, false);101 }, false);102 }103 var rmbutton = document.getElementById("removeMe2");104 if(rmbutton)105 {106 rmbutton.addEventListener("click", function(){107 removeAlert(emailtosend,prod_id);108 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';109 }, false);110 } 111 });112 113 114}//closing of addToWatchList function115var imgURL2 = chrome.extension.getURL("watch-price1.png");116if($s('#pdp-buynow-rp').length>0){117 if(flagToDisp==0){118 $s('#pdp-buynow-rp:eq(0)').after('<div id="bhWidget"><a id="addWatchList" alt="Add to Watch List" title="Add to Watch List and get notifications on price drop" href="javascript:void();" class="fk-inline-block buy-btn fksk-buy-btn"><img style="margin-top:4px;" src=' + imgURL2 +'></a></div>');119 120 var button = document.getElementById("addWatchList");121 button.addEventListener("click", function(){ 122 addToWatchList();123 }, false);124 }125 else {126 $s('#pdp-buynow-rp:eq(0)').after(strToDisp);127 var button = document.getElementById("removeMe");128 button.addEventListener("click", function(){129 removeAlert(emailtosend,prod_id);130 document.getElementById('bhWidget').innerHTML = '<div class="line fk-font-12" style="margin-bottom: 4px;color:#0B6F06"><b>Thank You ! We appreciate your motive to save energy :)</b></div>';131 }, false);132 }133}134function getPrice()135{136 myPrice = $("input#productPrice").val();137 return myPrice;...

Full Screen

Full Screen

gallery.js

Source:gallery.js Github

copy

Full Screen

...18 function removeMe() {19 $('.Gallery').empty();20 addImgGallery();21 }22 function removeMe2() {23 $('img[deletethat]').remove();24 25 }26 /*_________________________________________________________________________________________________*/27 function column() { //Passer les images Gallery en Column28 imgGalleryColumn.style = 'flex-direction: column; align-content: center; margin: 10px';29 sizeImageColumn.style = 'width: 1200px; height: auto'30 }31 /*_________________________________________________________________________________________________*/32 function row() { //Passer les images Gallery en Row mosaïque33 imgGalleryRow.style = 'flex-direction: row;'34 }35 /*_________________________________________________________________________________________________*/36 function addImage() { //Fonction appeler lors du clic bouton pour ajouter une image dans la Gallery37 console.log(document.querySelector('#addImageText').value);38 let myAddImage = (document.querySelector('#addImageText').value); // Select de la valeur entrée dans la zone de text pour la mettre dans let myAddImage39 let imageUrl = document.createElement('img'); // Création de la balise <img> placer dans let imageUrl40 imageUrl.setAttribute('deletethat', 'oui');41 imageUrl.setAttribute('src', myAddImage); // Donne à la balise img l'attribut src et la valeur de myAddImage qui est la valeur rentré dans la zone de texte42 document.querySelector('.Gallery').appendChild(imageUrl); // Ajout de la balise img rempli dans la balise <div class=Gallery> 43 }44 /*_________________________________________________________________________________________________*/45 function addImgGallery() { // Ajoute les images dans la page Gallery46 imgGallery.forEach(element => { //Pour chaque élément du tableau imgGallery47 const imageGallery = document.createElement('img'); //Création d'une balise img48 imageGallery.src = element; //Ajout de l'attribut src dans la balise img49 const newGallery = document.querySelector(".Gallery") //Select <div class=Gallery> pour mettre la valeur dans const newGallery50 newGallery.appendChild(imageGallery); //Ajout de la valeur de imageGallery dans la balise newGallery qui est <div class=Gallery>51 })52 }53 /*_________________________________________________________________________________________________*/54 function displayMenu() { /*bouton Menu basculer entre masquer et afficher le contenu de la liste déroulante */55 document.getElementById("myDropdown").classList.toggle("show");56 }57 /* //////////////////////////////////////// FONCTION & LOG CALL //////////////////////////////////////// */58 console.log(imgGallery);59 addImgGallery();60 //addImage();61 /* //////////////////////////////////////// MES EVENEMENTS //////////////////////////////////////// */62 $('#myButtonColumn').click(event => { column(); }) // lors du clic les images passe en Column63 $('#myButtonRow').click(event => { row(); }) // lors du clic les images passe en Row Mosaïque64 //lors du clic , ajoute l'image du lien mis dans la zone text65 document.querySelector('#myAddButtonImage').addEventListener('click', function() { addImage(); })66 $('#myButtonDelete').click(event => { removeMe2(); })67 $('.dropbtn').on("click", displayMenu);...

Full Screen

Full Screen

q.spec.js

Source:q.spec.js Github

copy

Full Screen

1describe("core.Q", function(){2 var Q = core && core.Q;3 it("should exist", function(){4 expect(Q).toBeDefined();5 });6 it("should create an instance of then, which takes cbs, and execs them", function(){7 var q = Q(),8 check = [];9 q(function(){10 expect(this).toBe(q);11 check.push(1);12 });13 q(function(){14 check.push("two");15 });16 q();17 expect(check).toEqual([1, 'two']);18 });19 it("should be installable onto an obj", function(){20 var obj = {},21 check = [];22 obj.test = Q.installer(obj);23 obj.test(function(){24 expect(this).toBe(obj);25 expect(arguments[0]).toEqual(1);26 expect(arguments[1]).toEqual('two');27 check.push(1);28 });29 obj.test(function(){30 expect(arguments[0]).toEqual(1);31 expect(arguments[1]).toEqual('two');32 check.push(2);33 });34 obj.test(1, 'two');35 expect(check).toEqual([1,2]);36 });37 it("should create removeable cbs", function(){38 var obj = {};39 obj.test = Q.installer(obj);40 var removeMe = function(){41 expect(false).toBe(true); // make sure this doesn't run42 };43 // add this fn as cb, but store a handle to the fn44 var removeMe2 = obj.test(removeMe);45 // obj.test(); // uncomment to ensure fail46 // remove via splice47 obj.test.remove(removeMe);48 // make sure its removed49 obj.test();50 // add it again51 obj.test(removeMe);52 // obj.test(); // uncomment to ensure fail53 removeMe2.remove(); // comment this to fail54 obj.test();55 expect(true).toBe(true);56 });...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

...24 todRow3.remove(); 25 twoElement.innerText = number;26 fiveElement.innerText = number2;27}28function removeMe2() {29 number --;30 todRow3.remove(); 31 twoElement.innerText = number;32}33function changeName() {34 OG.innerText = newName;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('removeMe2', () => {2})3Cypress.Commands.add('removeMe3', () => {4})5Cypress.Commands.add('removeMe4', () => {6})7Cypress.Commands.add('removeMe5', () => {8})9Cypress.Commands.add('removeMe6', () => {10})11Cypress.Commands.add('removeMe7', () => {12})13Cypress.Commands.add('removeMe8', () => {14})15Cypress.Commands.add('removeMe9', () => {16})17Cypress.Commands.add('removeMe10', () => {18})19Cypress.Commands.add('removeMe2', () => {20})21Cypress.Commands.add('removeMe3', () => {22})23Cypress.Commands.add('removeMe4', () => {24})25Cypress.Commands.add('remove

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.removeMe2();2cy.removeMe();3cy.removeMe3();4cy.removeMe4();5cy.removeMe5();6cy.removeMe6();7cy.removeMe7();8cy.removeMe8();9cy.removeMe9();10cy.removeMe10();11cy.removeMe11();12cy.removeMe12();13cy.removeMe13();14cy.removeMe14();15cy.removeMe15();16cy.removeMe16();17cy.removeMe17();18cy.removeMe18();19cy.removeMe19();20cy.removeMe20();21cy.removeMe21();22cy.removeMe22();23cy.removeMe23();24cy.removeMe24();25cy.removeMe25();26cy.removeMe26();27cy.removeMe27();28cy.removeMe28();29cy.removeMe29();30cy.removeMe30();31cy.removeMe31();32cy.removeMe32();

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('button').contains('Remove Me 2').click();2cy.get('button').contains('Remove Me 3').click();3cy.get('button').contains('Remove Me 4').click();4cy.get('button').contains('Remove Me 5').click();5cy.get('button').contains('Remove Me 6').click();6cy.get('button').contains('Remove Me 7').click();7cy.get('button').contains('Remove Me 8').click();8cy.get('button').contains('Remove Me 9').click();9cy.get('button').contains('Remove Me 10').click();10cy.get('button').contains('Remove Me 11').click();11cy.get('button').contains('Remove Me 12').click();12cy.get('button').contains('Remove Me 13').click();13cy.get('button').contains('Remove Me 14').click();14cy.get('button').contains('Remove Me 15').click();15cy.get('button').contains('Remove Me 16').click();16cy.get('button').contains('Remove Me 17').click();17cy.get('

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('button').contains('Remove Me 2').removeMe2();2Cypress.Commands.add('removeMe2', { prevSubject: 'element' }, (subject) => {3 cy.log('Remove Me 2 called');4 cy.wrap(subject).should('be.visible');5 cy.wrap(subject).click();6 cy.wrap(subject).should('not.exist');7});

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should remove me', () => {2 cy.get('.home-list > :nth-child(1) > .home-list-item').invoke('text').then((text) => {3 expect(text.trim()).equal('Kitchen Sink')4 })5 cy.contains('type').click()6 cy.url().should('include', '/commands/actions')7 cy.get('.action-email')8 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.removeMe2()2cy.removeMe2()3Cypress.Commands.add('removeMe2', () => {4 cy.log('removeMe2 method called');5})6Cypress.Commands.add('removeMe2', () => {7 cy.log('removeMe2 method called');8})9Cypress.Commands.overwrite('visit', (originalFn, url, options) => {10 cy.log('visit method called');11 return originalFn(url, options);12})13Cypress.Commands.add('visit', (url, options) => {14 cy.log('visit method called');15})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input').type('Hello')2cy.get('input').removeMe2()3cy.get('input').type('Hello')4cy.get('input').removeMe()5cy.get('input').type('Hello')6cy.get('input').removeMe()7cy.get('input').type('Hello')8cy.get('input').removeMe()9cy.get('input').type('Hello')10cy.get('input').removeMe2()11cy.get('input').type('Hello')12cy.get('input').removeMe()13cy.get('input').type('Hello')14cy.get('input').removeMe()15cy.get('input').type('Hello')16cy.get('input').removeMe()17cy.get('input').type('Hello')18cy.get('input').removeMe2()19cy.get('input').type('Hello')20cy.get('input').removeMe()21cy.get('input').type('Hello')22cy.get('input').removeMe()23cy.get('input').type('Hello')24cy.get('input').removeMe()25cy.get('input').type('Hello')26cy.get('input').removeMe2()27cy.get('input').type('Hello')28cy.get('input').removeMe()29cy.get('input').type('Hello')30cy.get('input').removeMe()31cy.get('input').type('Hello')32cy.get('input').removeMe()33cy.get('input').type('Hello')34cy.get('input').removeMe2()35cy.get('

Full Screen

Using AI Code Generation

copy

Full Screen

1const removeMe2 = require('../lib/removeMe2.js');2describe('Test removeMe2', () => {3 it('should remove the first two elements', () => {4 expect(removeMe2([1, 2, 3, 4])).to.eql([3, 4]);5 });6});7const removeMe2 = (arr) => {8 return arr.slice(2);9};10module.exports = removeMe2;

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.removeMe2()2Cypress.Commands.add('removeMe2', () => {3 cy.get('div').then(($div) => {4 if ($div.length > 0) {5 cy.get('div').remove()6 }7 })8})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful