gitbook-plugin-lock
Advanced tools
Comparing version 0.0.64 to 0.0.65
205
index.js
@@ -13,11 +13,11 @@ | ||
module.exports = { | ||
website: { | ||
assets: './assets', | ||
css: [ | ||
'lock.css' | ||
], | ||
js: [ | ||
'lock.js' | ||
] | ||
}, | ||
// website: { | ||
// assets: './assets', | ||
// css: [ | ||
// 'lock.css' | ||
// ], | ||
// js: [ | ||
// 'lock.js' | ||
// ] | ||
// }, | ||
hooks: { | ||
@@ -36,2 +36,62 @@ init() { | ||
console.log(page.content.search("%pageLock%"),"看看匹配情况") | ||
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("验证码不正确!") | ||
} | ||
} | ||
page.content.replaceAll(new RegExp('%pageLock%','g'),'<p></p>') | ||
return page; | ||
@@ -44,5 +104,2 @@ } | ||
// tokenValue = config.lock.tokenValue || 'lockName'; | ||
@@ -57,64 +114,64 @@ // wechatName = config.lock.wechatName || ''; | ||
// 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("验证码不正确!") | ||
// } | ||
// } | ||
// | ||
// } | ||
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.64", | ||
"version": "0.0.65", | ||
"description": "Gitbook 页面加锁", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
16102
261