show word of shanbay
目前為
// ==UserScript==
// @name shanbay_word
// @description:en show word of shanbay
// @namespace https://github.com/chenshengzhi
// @homepageURL https://greasyfork.org/zh-CN/scripts/18161
// @include *www.shanbay.com*
// @version 0.0.11
// @grant none
// @description show word of shanbay
// ==/UserScript==
function keyDownHandle(event) {
if (event.keyCode == 57 || event.keyCode == 105) {
setTimeout(function () {
document.activeElement.value = document.activeElement.getAttribute('data')
console.log(document.activeElement.value);
}, 50);
}
}
function addCircleButton(title, url, index) {
var btn = document.createElement("input");
btn.type = "button";
btn.value = title;
btn.style.position = 'fixed';
var top = (30 + 60 * index) + 'px';
btn.style.top = top;
btn.style.right = '30px';
btn.style.width = '60px';
btn.style.height = '60px';
btn.style.backgroundColor = '#208F72';
btn.style.borderStyle = 'none';
btn.style.borderRadius = '30px';
btn.style.color = 'white';
btn.style.fontSize = '16px';
btn.onclick = function(){
window.location.href = url;
};
document.body.appendChild(btn);
}
String.prototype.endWith = function(str) {
var reg = new RegExp(str + "$");
return reg.test(this);
}
var href = window.location.href;
var targetLocation = 'www.shanbay.com/listen/';
if (href.indexOf(targetLocation) >= 0) {
if (href.endWith(targetLocation)) {
document.getElementsByClassName("section sentence")[0].style = "display: none;";
document.getElementsByClassName("section article")[0].style = "display: none;";
document.getElementsByClassName("entry sentence hide")[0].style = "display: block;";
document.getElementsByClassName("entry article hide")[0].style = "display: block;";
} else {
document.onkeydown = keyDownHandle;
}
}
addCircleButton('听力\n列表', "https://www.shanbay.com/listen", 0);
addCircleButton('新闻\n列表', "https://www.shanbay.com/read/news/", 1);