${item.title}${item.key ? '
': '
'}${selecedGame.includes(item.name) ? '
' : '
'}
${getLock(item)}
`
gamelist.appendChild(li)
})
const view = document.querySelector('.content-choices-view')
const list = document.querySelector(".content-choice-tiles.js-content-choice-tiles")
view.insertBefore(gameBox, list)
sButton.addEventListener('click', () => {
if(sButton.classList.contains('current')){
gamelist.style.display = 'block'
sButton.innerHTML === '隐藏锁区信息'
}else {
gamelist.style.display = 'none'
sButton.innerHTML === '显示锁区信息'
}
sButton.classList.toggle('current')
} )
const noGetList = document.querySelectorAll('.no-get')
const noSelectList = document.querySelectorAll('.no-select')
noSelectList.forEach(item => {
item.addEventListener('click', clickEvent(true, {url: `https://www.humblebundle.com/humbler/choosecontent?gamekey=${gamekey}&parent_identifier=initial&chosen_identifier=${item.title}`}))
})
noGetList.forEach(item => {
item.addEventListener('click', clickEvent(false, {url: 'https://www.humblebundle.com/humbler/redeemkey', body: `keytype=${item.dataset.machine_name}&key=${gamekey}&keyindex=0`, method: 'POST'}))
})
function fetchHttp(data) {
return fetch(data.url, {
method: data.method || 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
Origin: 'https://www.humblebundle.com',
Referer: location.href
},
body: data.body,
credentials: 'same-origin'
})
}
function clickEvent (flag, data) {
return function request () {
if((this.innerText === '已选择') || (this.innerText === '已刮开') || (selecedGame.length >= 10)) return
this.innerText = '请求中...'
fetchHttp(data)
.then(res => res.json())
.then(res => {
if(!res.success){
return (this.innerText = flag ? '未选择' : '未刮开')
}
this.removeEventListener('click', request)
this.innerText = flag ? '已选择' : '已刮开'
this.className = 'current'
keyValue.value = ''
if(!flag) keyValue.value += `${this.title}: ${res.key}\n`
else keyValue.value += `${this.title}: 选择成功\n`
})
}
}
GM_addStyle(`
._sh_hd_ {
border: none;
outline: none;
background-color: #c93756;
margin: 20px 0 0 20px;
border-radius: 5px;
line-height: 50px;
padding: 0 20px;
}
._down_page_{
float: right;
padding: 0 20px;
border-radius: 5px;
height: 50px;
margin: 20px 20px 0 0;
line-height: 50px;
background-color: rgb(22, 159, 227);
color: #fff;
text-decoration: none;
}
._key_value_ {
margin: 20px 0 0 20px;
width: 800px;
height: 200px;
resize: none;
font-size: 18px;
color: #fff;
margin-top: 20px;
outline: none;
background-color: #454c5e;
border: none;
}
._option_ul_, ._select_ul_ {
margin: 20px 0 0 20px;
height: 50px;
line-height: 50px;
display: flex;
list-style: none;
padding: 0;
}
._option_ul_ > li, ._select_ul_ > li {
height: 50px;
line-height: 50px;
background-color: rgb(22, 159, 227);
margin-right: 20px;
border-radius: 5px;
text-align: center;
padding: 0 20px;
color: #fff;
font-size: 16px;
cursor: pointer;
}
._select_ul_ > li {
background-color: #454c5e;
}
._select_ul_ > li.current {
background-color: rgb(22, 159, 227);
}
._game_num_ {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 1;
background-color: rgba(0, 0, 0, .3);
text-align: center;
font-size: 100px;
}
._sh_hd_.current {
background-color: #169fe3;
}
._self_view_ {
list-style: none;
margin: 20px 0 0 0;
padding: 0;
}
._self_view_ > li {
font-size: 16px;
padding: 20px 0 0px 20px;
border-bottom: 10px solid #454c5e;
display: flex;
justify-content: space-between;
}
._self_view_ > li button {
border: none;
outline: none;
background-color: #169fe3;
margin: 0 10px;
font-size: 16px;
border-radius: 0.8em;
padding: 5px 15px;
width: 100px;
float: right;
}
._self_view_ > li .current{
background-color: #c93756;
}
._self_view_ > li:last-child {
border: none;
}
`)
}
})();