567zw_yh

优化567中文网阅读页面

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        567zw_yh
// @namespace   [email protected]
// @description 优化567中文网阅读页面
// @include     http://221.233.60.100:81/book_j.php?*
// @grant       none
// @version 0.0.1.20160309060717
// ==/UserScript==
var reg;
var booktext = document.getElementById('booktext');
var orgText = booktext.innerHTML;
var newText;
//去掉<br>
reg = new RegExp('<br>\n<br>', 'g');
newText = booktext.innerHTML.replace(reg, '');
//去掉多余的空格
reg = new RegExp('([ ])+', 'g');
newText = newText.replace(reg, '');
//加上<p>
reg = new RegExp('([一-龥]|[“”,。!?:…()、—*])+', 'g');
newText = newText.replace(reg, function (strMatch) {
  return '<p>&nbsp;&nbsp;' + strMatch + '</p>'
});
booktext.innerHTML = newText;
//调整行高
var Tp = document.getElementsByTagName('p');
for (var i = 0; i < Tp.length; i++) {
  Tp[i].style.lineHeight = '140%';
}
//工具栏滚动

window.onscroll = function () {
  var t = document.documentElement.scrollTop || document.body.scrollTop;
  var topTool = document.getElementsByClassName('toptool') [0];
  topTool.style.top = 0;
  if (t > topTool.offsetHeight) {
    topTool.style.position = 'fixed';
  } else {
    topTool.style.position = '';
  }
}