gitbook-plugin-lock
Advanced tools
Comparing version 0.0.61 to 0.0.62
102
index.js
@@ -0,1 +1,12 @@ | ||
let tokenValue; | ||
let wechatName; | ||
let wechatQr; | ||
let verificationCode; | ||
let thisCode; | ||
let thisValue; | ||
const lockTokenKey = "lock-token" | ||
module.exports = { | ||
@@ -10,5 +21,96 @@ website: { | ||
] | ||
}, | ||
hook: { | ||
init() { | ||
let pageLockConfig = this.config.get('pluginsConfig.lock'); | ||
tokenValue = pageLockConfig.tokenValue || 'lockName'; | ||
wechatName = pageLockConfig.wechatName || ''; | ||
wechatQr = pageLockConfig.wechatQr || ''; | ||
verificationCode = pageLockConfig.verificationCode || ''; | ||
const rand = Math.floor(Math.random() * verificationCode.length) | ||
thisCode = verificationCode[rand]["key"] | ||
thisValue = verificationCode[rand]["value"] | ||
}, | ||
page(page){ | ||
console.log(page.content) | ||
} | ||
} | ||
}; | ||
// tokenValue = config.lock.tokenValue || 'lockName'; | ||
// wechatName = config.lock.wechatName || ''; | ||
// wechatQr = config.lock.wechatQr || ''; | ||
// verificationCode = config.lock.verificationCode || ''; | ||
// const rand = Math.floor(Math.random() * verificationCode.length) | ||
// thisCode = verificationCode[rand]["key"] | ||
// thisValue = verificationCode[rand]["value"] | ||
// function insertPageLock(e) { | ||
// // console.log(e.context) | ||
// // let s = e.context.("%pageLock%") | ||
// // console.log(s,e.context) | ||
// let authToken= localStorage.getItem(lockTokenKey) | ||
// if (authToken!==isNaN(0)||authToken!==""||authToken!==undefined) { | ||
// for (let i in verificationCode) { | ||
// if (verificationCode[i]["value"] === authToken) { | ||
// return true; | ||
// } | ||
// } | ||
// } | ||
// | ||
// const cla = document.getElementById("book-search-results"); | ||
// const article = cla, height = article.scrollHeight; | ||
// // 文章隐藏后的高度 | ||
// const halfHeight = height * 0.5; | ||
// cla.style.height= halfHeight + 'px'; | ||
// cla.style.overflow = 'hidden' | ||
// | ||
// | ||
// const html = '<div id="read-more-wrap" style="position: absolute; bottom: 0; z-index: 9999; width: 100%; margin-top: -100px; font-family: PingFangSC-Regular, sans-serif;">' + | ||
// '<div id="read-more-mask" style="position: relative; height: 200px; background: -webkit-gradient(linear, 0 0%, 0 100%, from(rgba(255, 255, 255, 0)), to(rgb(255, 255, 255)));"></div>' + | ||
// '<div class="info" style="position: absolute;left: 50%;top: 70%;bottom: 30px;transform: translate(-50%, -50%);font-size: 15px;text-align: center;background: -webkit-gradient(linear, 0 0%, 0 100%, from(rgba(255, 255, 255, 0)), to(rgb(255, 255, 255)));">\n' + | ||
// ' <div>扫码或搜索:<span style="color: #E9405A; font-weight: bold;">'+wechatName+'</span></div>\n' + | ||
// ' <div>\n' + | ||
// ' <span>发送 </span><span class="token" style="color: #e9415a; font-weight: bold; font-size: 17px; margin-bottom: 45px;">'+thisCode+'</span>\n' + | ||
// ' </div>\n' + | ||
// ' <div>\n' + | ||
// ' 即可<span style="color: #e9415a; font-weight: bold;">立即永久</span>解锁本站全部文章\n' + | ||
// ' </div>\n' + | ||
// ' <div id="btw-modal-input-code" style="margin-top: 20px; background: rgb(255, 255, 255);"><input '+ | ||
// ' id="btw-modal-input" type="text" maxLength="10" placeholder="请输入验证码" '+ | ||
// ' style="width: 160px; height: 32px; line-height: 32px; padding: 0 10px; margin: 0 10px; font-size: 13px; text-rendering: auto; text-transform: none; cursor: text; outline: none; box-sizing: border-box; border: 1px solid rgb(221, 221, 221); appearance: textfield; background-color: white; -webkit-rtl-ordering: logical;">'+ | ||
// ' <button onclick="bc()" id="btw-submit-btn" '+ | ||
// ' style="padding: 0 20px; height: 32px; font-size: 14px; outline: none; border: none; color: rgb(255, 255, 255); background: rgb(222, 104, 109); cursor: pointer;">提 '+ | ||
// ' 交'+ | ||
// ' </button></div>\n '+ | ||
// ' <div>\n' + | ||
// ' <img class="code-img" style="width: 300px;display:unset" src="'+wechatQr+'">\n' + | ||
// ' </div>\n' + | ||
// '</div>' + | ||
// '</div>'; | ||
// | ||
// const child = document.createElement('div') | ||
// child.innerHTML = html | ||
// cla.appendChild(child) | ||
// bc = function () { | ||
// const val = document.getElementById('btw-modal-input').value | ||
// // alert(val+typeof val+thisValue) | ||
// if (val === thisValue) { | ||
// cla.style.height= height + 'px'; | ||
// cla.style.overflow= 'visible'; | ||
// const rm = document.getElementById("read-more-wrap") | ||
// rm.parentNode.removeChild(rm) | ||
// localStorage.setItem(lockTokenKey,thisValue) | ||
// } else { | ||
// alert("验证码不正确!") | ||
// } | ||
// } | ||
// | ||
// } | ||
{ | ||
"name": "gitbook-plugin-lock", | ||
"version": "0.0.61", | ||
"version": "0.0.62", | ||
"description": "Gitbook 页面加锁", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
12150
207