This commit is contained in:
liushiwei
2024-07-18 14:48:44 +08:00
parent 6356004d74
commit 0808f42ce7
37 changed files with 2456 additions and 158 deletions

274
public/js/temuSeller.js Normal file
View File

@@ -0,0 +1,274 @@
function matchTemuDomain(url) {
const urlPattern = /https:\/\/([\da-z\.-]+)\.kuajingmaihuo\.com\//
return urlPattern.test(url);
}
function init() {
if (matchTemuDomain(window.location.href)) {
let j = 0
let timer = setInterval(() => {
let models = document.querySelectorAll('div[class^="MDL_header"]')
let flag = false
for (let i = 0; i < models.length; i++) {
if (models[i].textContent.includes("商品降价提醒") || models[i].textContent.includes("降价,提升竞争力,避免限制备货")) {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
padding: "8px",
background: "#fb7701",
color: "#fff",
display: 'inline',
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
models[i].appendChild(popup)
popup.addEventListener('click', async () => {
let tbodyObj = models[i].parentElement.querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let firstLabelObj = tdObj.querySelector('div label:first-child')
if (firstLabelObj.getAttribute("data-checked")) {
let labelObj = tdObj.querySelector('div label:nth-child(2)')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
})
flag = true
}
}
let models2 = document.querySelectorAll('div[class^="price-adjust-confirm-system_contentWrp"]')
for (let i = 0; i < models2.length; i++) {
let tipsObj = models2[i].querySelector('div[class^="price-adjust-confirm-system_tips"]')
let spanObj = tipsObj.querySelector('div span:last-child')
if (spanObj) {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
padding: "8px",
background: "#fb7701",
color: "#fff",
display: 'inline',
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
spanObj.appendChild(popup)
popup.addEventListener('click', async () => {
let tbodyObj = models2[i].querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let firstLabelObj = tdObj.querySelector('div label:first-child')
if (firstLabelObj.getAttribute("data-checked")) {
let labelObj = tdObj.querySelector('div label:nth-child(2)')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
})
flag = true
}
}
let models3 = document.querySelectorAll('div[class^="price-adjust-confirm-new_content"]')
for (let i = 0; i < models3.length; i++) {
let tipsObj = models3[i].querySelector('div[class^="price-adjust-confirm-new_tips"]')
let spanObj = tipsObj.querySelector('div span:last-child')
if (spanObj) {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
padding: "8px",
background: "#fb7701",
color: "#fff",
display: 'inline',
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
spanObj.appendChild(popup)
popup.addEventListener('click', async () => {
let tbodyObj = models3[i].querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let firstLabelObj = tdObj.querySelector('div label:first-child')
if (firstLabelObj.getAttribute("data-checked")) {
let labelObj = tdObj.querySelector('div label:nth-child(2)')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
})
flag = true
}
}
let models4 = document.querySelectorAll('div[class^="price-adjust-confirm-system-old_contentWrp"]')
for (let i = 0; i < models4.length; i++) {
let tipsObj = models4[i].querySelector('div[class^="price-adjust-confirm-system-old_tips"]')
let spanObj = tipsObj.querySelector('div span:last-child')
if (spanObj) {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
padding: "8px",
background: "#fb7701",
color: "#fff",
display: 'inline',
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
spanObj.appendChild(popup)
popup.addEventListener('click', async () => {
let tbodyObj = models4[i].querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let firstLabelObj = tdObj.querySelector('div label:first-child')
if (firstLabelObj.getAttribute("data-checked")) {
let labelObj = tdObj.querySelector('div label:nth-child(2)')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
})
flag = true
}
}
let models5 = document.querySelectorAll('div[class^="new-price-adjust-confirm_content"]')
for (let i = 0; i < models5.length; i++) {
let tipsObj = models5[i].querySelector('div[class^="new-price-adjust-confirm_tips"]')
let spanObj = tipsObj.querySelector('div span:last-child')
if (spanObj) {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
padding: "8px",
background: "#fb7701",
color: "#fff",
display: 'inline',
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
spanObj.appendChild(popup)
popup.addEventListener('click', async () => {
let tbodyObj = models5[i].querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let firstLabelObj = tdObj.querySelector('div label:first-child')
if (firstLabelObj.getAttribute("data-checked")) {
let labelObj = tdObj.querySelector('div label:nth-child(2)')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
})
flag = true
}
}
if (flag) {
clearInterval(timer)
} else {
j++
if (j == 10) {
clearInterval(timer)
}
}
}, 3000)
// document.body.appendChild(popup)
}
}
/*
function createElement() {
const popup = document.createElement("div")
popup.innerText = "拒绝调价"
const styles = {
position: "fixed",
right: '10px',
top: '60px',
zIndex: 999999,
padding: "8px",
background: "#409EFF",
color: "#fff",
borderRadius: "8px",
cursor: "pointer"
}
for (const e in styles) {
popup.style[e] = styles[e]
}
popup.addEventListener('click', async () => {
let divObj1 = document.querySelector('div[class^="price-adjust-confirm-system_contentWrp"]')
if (divObj1) {
let tbodyObj = divObj1.querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let labelObj = tdObj.querySelector('div label:last-child')
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
// await sleepSync(50)
radioObj.click()
}
}
let divObj2 = document.querySelector('div[class^="price-adjust-confirm_header"]')
if (divObj2) {
let divObj = divObj2.nextElementSibling
let tbodyObj = divObj.querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let labelObj = tdObj.querySelector('div label:last-child')
//let radioObj = labelObj.querySelector("[type='radio']")
// await sleepSync(50)
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
radioObj.click()
}
}
let divObj3 = document.querySelector('div[class^="price-adjust-confirm-new_banner"]')
if (divObj3) {
let divObj = divObj3.nextElementSibling
let tbodyObj = divObj.querySelector('tbody')
let trList = tbodyObj.querySelectorAll('tr')
for (let i = 0; i < trList.length; i++) {
let tdObj = trList[i].querySelector('td:last-child')
let labelObj = tdObj.querySelector('div label:last-child')
//let radioObj = labelObj.querySelector("[type='radio']")
// await sleepSync(50)
let radioObj = labelObj.querySelector('div[class^="RD_radioWrapper"]')
radioObj.click()
}
}
})
return popup
}
*/
init()

View File

@@ -0,0 +1,8 @@
function injectScript(file, node) {
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
th.appendChild(s);
}
injectScript( chrome.runtime.getURL('/js/temuSeller.js'), 'body');