-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbphones.js
60 lines (46 loc) · 1.69 KB
/
wbphones.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(() => {
const getItem = (name, phone) => {
const data = JSON.parse(sessionStorage.getItem('wbdataxxxx') || '[]');
const _phone = phone.slice(-5).replace('-', '');
return data.find(item => {
const _name = item.buyer.name;
const mobile = item.buyer.mobile.toString();
return mobile.slice(-4) === _phone && name === _name;
})
};
if (document.title.indexOf("WBPoint") != -1) {
const SSKEY = 'wbdataxxxx';
var s = document.createElement('script');
s.src = chrome.runtime.getURL('wbrequest.js');
s.onload = function() {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
let listNode = null;
let observer = new MutationObserver(mutations => {
for(let mutation of mutations) {
for(let addedNode of mutation.addedNodes) {
if ((addedNode?.tagName || '').toLowerCase() === 'app-ready-item') {
const nameNode = addedNode.querySelector('div.opp-item-data-entry span.opp-item-hoverlight');
const phoneNode = addedNode.querySelector('div.opp-item__cell--separated div.opp-item-data-entry--s span');
const user = getItem(nameNode.textContent, phoneNode.textContent);
if (user) {
phoneNode.innerHTML = user.buyer.mobile;
}
}
}
}
});
let safeCounter = 0;
const timer = setInterval(() => {
safeCounter++;
listNode = document.querySelector('.opp-manager--fw.opp-apps-list');
if (listNode) {
clearInterval(timer);
observer.observe(listNode, { childList: true, subtree: true });
}
if (safeCounter > 100)
clearInterval(timer);
}, 200);
}
})()