-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtiny-ab.js
More file actions
20 lines (15 loc) · 823 Bytes
/
Copy pathtiny-ab.js
File metadata and controls
20 lines (15 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const tinyABinit = () => {
const contentOriginal = document.getElementsByClassName('ab-test-original');
const contentAlt = document.getElementsByClassName('ab-test-alternative');
const id = wp_user_info.username.data.display_name;
const testCriteria = (contentAlt.length > 0) && (typeof id !== 'undefined');
testCriteria ? runTinyAB(contentOriginal, contentAlt, id) : removeElements(contentAlt);
}
const removeElements = (group) => Array.from(group).forEach(element => element.remove());
const runTinyAB = (contentOriginal, contentAlt, id) => {
const lastChar = id.slice(-1);
const altChars = ['1', '3', '5', '7', '9', 'b', 'd', 'f'];
const showAlt = altChars.includes(lastChar);
showAlt ? removeElements(contentOriginal) : removeElements(contentAlt);
}
tinyABinit();