Created
August 6, 2018 03:49
-
-
Save arieffikhrie/5bd027aa0af24f904ff2c614963864a1 to your computer and use it in GitHub Desktop.
http://timepaz.com/EyeTest/ eyetest cheat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script only can be used at http://timepaz.com/EyeTest/ , just open console and copied this code | |
var _$ = jQuery; | |
var $div = _$('#box'); | |
var observer = new MutationObserver(function (mutations) { | |
mutations.forEach(function (mutation) { | |
if (mutation.attributeName === "class") { | |
const attributeValue = $(mutation.target).prop(mutation.attributeName); | |
const mapElem = {}; | |
const currentClass = ''; | |
$div.on('event', () => { | |
const item = _$(this); | |
console.log('class', currentClass, item.prop('class')); | |
}); | |
$div.find('span').each((index, elem) => { | |
const bgColor = _$(elem).css('backgroundColor'); | |
console.log(bgColor); | |
if (typeof mapElem[bgColor] === 'undefined') { | |
mapElem[bgColor] = { | |
color: bgColor, | |
count: 1, | |
elem: _$(elem), | |
index: index | |
} | |
} else { | |
mapElem[bgColor].count++; | |
mapElem[bgColor].elem = _$(elem); | |
mapElem[bgColor].index = index; | |
} | |
}).promise().done(() => { | |
console.log(mapElem); | |
for (let key in mapElem) { | |
const item = mapElem[key]; | |
if (item.count === 1) { | |
item.elem.css('backgroundColor', 'white'); | |
} | |
} | |
}); | |
} | |
}); | |
}); | |
observer.observe($div[0], { | |
attributes: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _$=jQuery;var $div=_$('#box');var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.attributeName==="class"){const attributeValue=$(mutation.target).prop(mutation.attributeName);const mapElem={};const currentClass='';$div.on('event',()=>{const item=_$(this);console.log('class',currentClass,item.prop('class'))});$div.find('span').each((index,elem)=>{const bgColor=_$(elem).css('backgroundColor');console.log(bgColor);if(typeof mapElem[bgColor]==='undefined'){mapElem[bgColor]={color:bgColor,count:1,elem:_$(elem),index:index}}else{mapElem[bgColor].count++;mapElem[bgColor].elem=_$(elem);mapElem[bgColor].index=index}}).promise().done(()=>{console.log(mapElem);for(let key in mapElem){const item=mapElem[key];if(item.count===1){item.elem.css('backgroundColor','white')}}})}})});observer.observe($div[0],{attributes:!0}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment