From 186e819d60518d3d9adee540edb1bedc5b5dc3e7 Mon Sep 17 00:00:00 2001 From: ldxw Date: Sat, 1 Feb 2020 04:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20onedrive=5Fscf=20=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E7=BE=8E=E5=8C=96js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scfone-theme-js/logi.js | 243 ++++++++++++++++++++++++++++++ scfone-theme-js/odscf/logi.js | 270 ++++++++++++++++++++++++++++++++++ 2 files changed, 513 insertions(+) create mode 100644 scfone-theme-js/logi.js create mode 100644 scfone-theme-js/odscf/logi.js diff --git a/scfone-theme-js/logi.js b/scfone-theme-js/logi.js new file mode 100644 index 0000000..db8dc49 --- /dev/null +++ b/scfone-theme-js/logi.js @@ -0,0 +1,243 @@ +// 忽略异常 +const IGNORE_EXCEPTION = (funs) => funs.forEach(fun => { try { fun(); } catch (error) { } }); + +// 资源加载后回调 +const LOADED = (element, callback) => { + let loaded = false; + if (typeof callback === 'function') { + element.onload = element.onreadystatechange = () => { + if (!loaded && (!element.readyState || /loaded|complete/.test(element.readyState))) { + element.onload = element.onreadystatechange = null; + loaded = true; + callback(); + } + } + } +}; + +// 字符串模板 +const HEREDOC = (fn) => fn.toString().split('\n').slice(1, -1).join('\n') + '\n'; + +// 自定义字体 +const FONT_PINGYONG = HEREDOC(() => {/* + + */}); + +// 雨伞背景 +const ADD_UMBRELLA_BACKGROUND = (callback) => { + const SCRIPT = document.createElement('script'); + SCRIPT.src = '//s0.pstatp.com/cdn/expire-1-M/canvas-nest.js/2.0.4/canvas-nest.js'; + SCRIPT.opacity = '0.1'; + SCRIPT.zIndex = '-99'; + SCRIPT.count = '10'; + LOADED(SCRIPT, callback); + document.body.appendChild(SCRIPT); +}; + +const ADD_IMGAGE_BACKGROUND = () => { + const IMAGE = 'url(https://img12.360buyimg.com/img/jfs/t1/56992/25/15607/359235/5dc93624E8223dc25/41cac0ada12d3ad9.jpg)' + const DIV = document.createElement('div'); + DIV.style.background = IMAGE; + DIV.style.pointerEvents = 'none'; + DIV.style.backgroundRepeat = 'no-repeat'; + DIV.style.backgroundSize = 'cover'; + DIV.style.position = 'fixed'; + DIV.style.left = '0'; + DIV.style.top = '0'; + DIV.style.width = '100%'; + DIV.style.height = '100%'; + DIV.style.filter = 'blur(2px)'; + DIV.style.msFilter = 'blur(2px)'; + DIV.style.webkitFilter = 'blur(2px)'; + DIV.style.mozFilter = 'blur(2px)'; + DIV.style.oFilter = 'blur(2px)'; + DIV.style.opacity = '0.2'; + document.body.appendChild(DIV); +}; + +// 移除 README.md +const REMOVE_README = () => { + const TBODY = document.querySelector('#list-table').querySelector('tbody'); + const TRS = TBODY.querySelectorAll('tr'); + let readme = null; + TRS.forEach(TR => { + const A = TR.querySelector('a'); + if (A && A.href.indexOf('README.md') >= 0) { + readme = TR; + return; + } + }); + readme ? TBODY.removeChild(readme) : null; +}; + +// 时间和 IP 居中显示,时间走动 +const ADD_TIME_AND_IP = () => { + // 居中并显示 + const CENTER = document.createElement('center'); + CENTER.style.paddingBottom = '40px'; + const FONT = document.body.querySelector('font'); + FONT.id = 'date'; + FONT.removeAttribute('color'); + CENTER.appendChild(FONT); + document.body.insertBefore(CENTER, document.body.querySelector('#mask')); + + // 时间走动 + setInterval(() => { + const ADDZERO = num => num < 10 ? '0' + num : num; const FUN_WEEK = week => '日一二三四五六'[week]; + + const DATE = new Date(); + const YEAR = DATE.getFullYear(); + const MONTH = DATE.getMonth() + 1; + const DAY = DATE.getDate(); + const HOURS = DATE.getHours(); + const MINUTES = DATE.getMinutes(); + const SECONDS = DATE.getSeconds(); + const WEEK = DATE.getDay(); + + const ELEMENT = document.querySelector('#date'); + const IP = ELEMENT.innerHTML.split(' ').pop(); + ELEMENT.innerHTML = 'yyyy-mm-dd hh:MM:ss 星期w' + .replace('yyyy', YEAR) + .replace('mm', ADDZERO(MONTH)) + .replace('dd', ADDZERO(DAY)) + .replace('hh', ADDZERO(HOURS)) + .replace('MM', ADDZERO(MINUTES)) + .replace('ss', ADDZERO(SECONDS)) + .replace('w', FUN_WEEK(WEEK)) + + ' ' + IP; + }, 1000); +}; + +// 其他 UI +const CHANGE_OHTER_UI = () => { + // 标题 + document.head.innerHTML += FONT_PINGYONG + const TITLE = document.body.querySelector('.title'); + TITLE.style.margin = '0'; + TITLE.style.lineHeight = '2em'; + TITLE.style.fontSize = '300%'; + TITLE.style.fontFamily = 'PinyonScript'; + + // 语言选择框 + const LANGUAGES = document.body.querySelector('.changelanguage'); + if (screen.width < 800) { + // 移动端隐藏 + LANGUAGES.style.display = 'none'; + } else { + LANGUAGES.style.position = 'fixed'; + LANGUAGES.style.top = '5px'; + LANGUAGES.style.outline = 'none'; + LANGUAGES.style.borderRadius = '2em'; + LANGUAGES.style.height = '1.5em'; + } + + // 左上角管理 + const OPERATE = document.body.querySelector('.operate'); + if (OPERATE) { + OPERATE.style.position = 'fixed'; + OPERATE.style.top = '5px'; + OPERATE.style.left = '5px'; + OPERATE.style.border = '1px #00000066 solid'; + OPERATE.style.borderRadius = '2em'; + OPERATE.style.background = 'white'; + OPERATE.style.minWidth = '3em'; + OPERATE.style.textAlign = 'center'; + OPERATE.style.lineHeight = '1.3em'; + } + + // BODY + document.body.style = ''; + document.body.zIndex = '99'; + document.body.style.margin = '0'; + document.body.style.padding = '0'; + // 文件列表和 README 阴影 + const LIST_WRAPPERs = document.body.querySelectorAll('.list-wrapper'); + LIST_WRAPPERs.forEach(WRAPPER => { + WRAPPER.style.boxShadow = '0 0 32px 0 rgba(128, 128, 128, 0.18)'; + }); + // 文件列表圆角 + const LTFILEs = document.body.querySelectorAll('.list-table .file'); + LTFILEs.forEach(FILE => { + FILE.style.borderRadius = '25px 0px 0px 25px'; + }); + const LTSIZEs = document.body.querySelectorAll('.list-table .size'); + LTSIZEs.forEach(SIZE => { + SIZE.style.borderRadius = '0px 25px 25px 0px'; + }); + // 文件路径行距 + const THEADER = document.body.querySelector('.list-header-container .table-header'); + THEADER.style.lineHeight = '1.3em'; + + // 移动端隐藏修改时间 + if (screen.width < 800) { + const LTUPDATEATs = document.body.querySelectorAll('.list-table .updated_at'); + LTUPDATEATs.forEach(UPDATEAT => { + UPDATEAT.style.display = 'none'; + }); + } + // 按钮 + const BUTTONs = document.body.querySelectorAll('button'); + BUTTONs.forEach(BUTTON => { + BUTTON.style.border = '1px #00000066 solid'; + BUTTON.style.borderRadius = '2em'; + BUTTON.style.background = 'white'; + }); + const SUBMITs = document.body.querySelectorAll('input[type="submit" i]'); + SUBMITs.forEach(SUBMIT => { + SUBMIT.style.border = '1px #00000066 solid'; + SUBMIT.style.borderRadius = '2em'; + SUBMIT.style.background = 'white'; + SUBMIT.style.minWidth = '5em'; + }); + const FILE_BUTTONs = document.body.querySelectorAll('input[type="button" i]'); + FILE_BUTTONs.forEach(FBUTTON => { + FBUTTON.style.border = '1px #00000066 solid'; + FBUTTON.style.borderRadius = '2em'; + FBUTTON.style.background = 'white'; + FBUTTON.style.minWidth = '5em'; + FBUTTON.style.height = '1.9em'; + }); + // 输入框 + const PASSWORDs = document.body.querySelectorAll('input[type="password" i], input[type="file" i]'); + PASSWORDs.forEach(PASSWORD => { + PASSWORD.style.outline = 'none'; + PASSWORD.style.textAlign = 'center'; + PASSWORD.style.lineHeight = '1.3em'; + PASSWORD.style.border = '1px #00000066 solid'; + PASSWORD.style.borderRadius = '2em'; + PASSWORD.style.background = 'white'; + PASSWORD.style.minWidth = '10em'; + }); + // URL + const URL = document.body.querySelector('#url'); + if (URL) { + URL.style.resize = 'none'; + URL.style.outline = 'none'; + URL.style.textAlign = 'center'; + URL.style.height = 'initial'; + URL.style.borderRadius = '2em'; + } +}; + +// 主函数 +const MAIN_HANDLER = () => { + IGNORE_EXCEPTION([ + ADD_IMGAGE_BACKGROUND, + ADD_UMBRELLA_BACKGROUND, + CHANGE_OHTER_UI, + REMOVE_README, + ADD_TIME_AND_IP + ]); + document.body.removeAttribute('hidden'); +}; + +// 文档加载完毕执行主函数 +document.addEventListener('DOMContentLoaded', MAIN_HANDLER); \ No newline at end of file diff --git a/scfone-theme-js/odscf/logi.js b/scfone-theme-js/odscf/logi.js new file mode 100644 index 0000000..1c3d060 --- /dev/null +++ b/scfone-theme-js/odscf/logi.js @@ -0,0 +1,270 @@ +// 针对 20200120.02 版本 +// 忽略异常 +const IGNORE_EXCEPTION = (funs) => funs.forEach(fun => { try { fun(); } catch (error) { } }); +// const IGNORE_EXCEPTION = (funs) => funs.forEach(fun => fun()); + +// 资源加载后回调 +const LOADED = (element, callback) => { + let loaded = false; + if (typeof callback === 'function') { + element.onload = element.onreadystatechange = () => { + if (!loaded && (!element.readyState || /loaded|complete/.test(element.readyState))) { + element.onload = element.onreadystatechange = null; + loaded = true; + callback(); + } + } + } +}; + +// 字符串模板 +const HEREDOC = (fn) => fn.toString().split('\n').slice(1, -1).join('\n') + '\n'; + +// 自定义字体 +const FONT_PINGYONG = HEREDOC(() => {/* + + */}); + +// 雨伞背景 +const ADD_UMBRELLA_BACKGROUND = (callback) => { + const SCRIPT = document.createElement('script'); + SCRIPT.src = '//s0.pstatp.com/cdn/expire-1-M/canvas-nest.js/2.0.4/canvas-nest.js'; + SCRIPT.opacity = '0.1'; + SCRIPT.count = '10'; + LOADED(SCRIPT, callback); + document.body.appendChild(SCRIPT); +}; + +const ADD_IMGAGE_BACKGROUND = () => { + const IMAGE = 'url(//img12.360buyimg.com/img/jfs/t1/56992/25/15607/359235/5dc93624E8223dc25/41cac0ada12d3ad9.jpg)' + const DIV = document.createElement('div'); + DIV.style.background = IMAGE; + DIV.style.pointerEvents = 'none'; + DIV.style.backgroundRepeat = 'no-repeat'; + DIV.style.backgroundSize = 'cover'; + DIV.style.position = 'fixed'; + DIV.style.left = '0'; + DIV.style.top = '0'; + DIV.style.width = '100%'; + DIV.style.height = '100%'; + DIV.style.filter = 'blur(2px)'; + DIV.style.msFilter = 'blur(2px)'; + DIV.style.webkitFilter = 'blur(2px)'; + DIV.style.mozFilter = 'blur(2px)'; + DIV.style.oFilter = 'blur(2px)'; + DIV.style.opacity = '0.2'; + document.body.appendChild(DIV); +}; + +// 移除 README.md +const REMOVE_README = () => { + const TBODY = document.querySelector('#list-table tbody'); + if (TBODY) { + const TRS = TBODY.querySelectorAll('tr'); + let readme = null; + TRS.forEach(TR => { + const A = TR.querySelector('a'); + if (A && A.href.indexOf('README.md') >= 0) { + readme = TR; + return; + } + }); + readme ? TBODY.removeChild(readme) : null; + } +}; + +// 时间和 IP 居中显示,时间走动 +const ADD_TIME_AND_IP = () => { + // 居中并显示 + const CENTER = document.createElement('center'); + CENTER.style.paddingBottom = '40px'; + const FONT = document.body.querySelector('font'); + FONT.id = 'date'; + FONT.removeAttribute('color'); + CENTER.appendChild(FONT); + document.body.insertBefore(CENTER, document.body.querySelector('#mask')); + + // 时间走动 + setInterval(() => { + const ADDZERO = num => num < 10 ? '0' + num : num; const FUN_WEEK = week => '日一二三四五六'[week]; + + const DATE = new Date(); + const YEAR = DATE.getFullYear(); + const MONTH = DATE.getMonth() + 1; + const DAY = DATE.getDate(); + const HOURS = DATE.getHours(); + const MINUTES = DATE.getMinutes(); + const SECONDS = DATE.getSeconds(); + const WEEK = DATE.getDay(); + + const ELEMENT = document.querySelector('#date'); + const IP = ELEMENT.innerHTML.split(' ').pop(); + ELEMENT.innerHTML = 'yyyy-mm-dd hh:MM:ss 星期w' + .replace('yyyy', YEAR) + .replace('mm', ADDZERO(MONTH)) + .replace('dd', ADDZERO(DAY)) + .replace('hh', ADDZERO(HOURS)) + .replace('MM', ADDZERO(MINUTES)) + .replace('ss', ADDZERO(SECONDS)) + .replace('w', FUN_WEEK(WEEK)) + + ' ' + IP; + }, 1000); +}; + +// 其他 UI +const CHANGE_OHTER_UI = () => { + // 标题 + document.head.innerHTML += FONT_PINGYONG; + const TITLE = document.body.querySelector('.title'); + TITLE.style.margin = '0'; + TITLE.style.lineHeight = '2em'; + TITLE.style.fontSize = '300%'; + TITLE.style.fontFamily = 'PinyonScript'; + + // 语言选择框 + const LANGUAGES = document.body.querySelector('.changelanguage'); + if (screen.width < 800) { + // 移动端隐藏 + LANGUAGES.style.display = 'none'; + } else { + LANGUAGES.style.position = 'fixed'; + LANGUAGES.style.top = '5px'; + LANGUAGES.style.outline = 'none'; + LANGUAGES.style.borderRadius = '2em'; + LANGUAGES.style.height = '1.5em'; + } + + // 左上角管理 + const OPERATE = document.body.querySelector('.operate'); + if (OPERATE) { + OPERATE.style.position = 'fixed'; + OPERATE.style.top = '5px'; + OPERATE.style.left = '5px'; + OPERATE.style.border = '1px #00000066 solid'; + OPERATE.style.borderRadius = '2em'; + OPERATE.style.background = 'white'; + OPERATE.style.minWidth = '3em'; + OPERATE.style.textAlign = 'center'; + OPERATE.style.lineHeight = '1.3em'; + } + + // 左上角登录 + const LOGIN = document.querySelector('a[onclick="login();"]'); + if (LOGIN) { + LOGIN.style.position = 'fixed'; + LOGIN.style.top = '5px'; + LOGIN.style.left = '5px'; + LOGIN.style.border = '1px #00000066 solid'; + LOGIN.style.borderRadius = '2em'; + LOGIN.style.background = 'white'; + LOGIN.style.minWidth = '3em'; + LOGIN.style.textAlign = 'center'; + LOGIN.style.lineHeight = '1.3em'; + } + + // BODY + document.body.style = ''; + document.body.zIndex = '99'; + document.body.style.margin = '0'; + document.body.style.padding = '0'; + // 文件列表和 README 阴影 + const LIST_WRAPPERs = document.body.querySelectorAll('.list-wrapper'); + LIST_WRAPPERs.forEach(WRAPPER => { + WRAPPER.style.boxShadow = '0 0 32px 0 rgba(128, 128, 128, 0.18)'; + }); + // 文件列表圆角 + const LTFILEs = document.body.querySelectorAll('.list-table .file'); + LTFILEs.forEach(FILE => { + FILE.style.borderRadius = '25px 0px 0px 25px'; + }); + const LTSIZEs = document.body.querySelectorAll('.list-table .size'); + LTSIZEs.forEach(SIZE => { + SIZE.style.borderRadius = '0px 25px 25px 0px'; + }); + // 文件路径行距 + const THEADER = document.body.querySelector('.list-header-container .table-header'); + THEADER.style.lineHeight = '1.3em'; + + // 移动端隐藏修改时间 + if (screen.width < 800) { + const LTUPDATEATs = document.body.querySelectorAll('.list-table .updated_at'); + LTUPDATEATs.forEach(UPDATEAT => { + UPDATEAT.style.display = 'none'; + }); + } + // 按钮 + const BUTTONs = document.body.querySelectorAll('button'); + BUTTONs.forEach(BUTTON => { + BUTTON.style.border = '1px #00000066 solid'; + BUTTON.style.borderRadius = '2em'; + BUTTON.style.background = 'white'; + }); + const SUBMITs = document.body.querySelectorAll('input[type="submit" i]'); + SUBMITs.forEach(SUBMIT => { + SUBMIT.style.border = '1px #00000066 solid'; + SUBMIT.style.borderRadius = '2em'; + SUBMIT.style.background = 'white'; + SUBMIT.style.minWidth = '5em'; + }); + const FILE_BUTTONs = document.body.querySelectorAll('input[type="button" i]'); + FILE_BUTTONs.forEach(FBUTTON => { + FBUTTON.style.border = '1px #00000066 solid'; + FBUTTON.style.borderRadius = '2em'; + FBUTTON.style.background = 'white'; + FBUTTON.style.minWidth = '5em'; + FBUTTON.style.height = '1.9em'; + }); + // 输入框 + const PASSWORDs = document.body.querySelectorAll('input[type="password" i], input[type="file" i]'); + PASSWORDs.forEach(PASSWORD => { + PASSWORD.style.outline = 'none'; + PASSWORD.style.textAlign = 'center'; + PASSWORD.style.lineHeight = '1.3em'; + PASSWORD.style.border = '1px #00000066 solid'; + PASSWORD.style.borderRadius = '2em'; + PASSWORD.style.background = 'white'; + PASSWORD.style.minWidth = '10em'; + }); + // URL + const URL = document.body.querySelector('#url'); + if (URL) { + URL.style.resize = 'none'; + URL.style.outline = 'none'; + URL.style.textAlign = 'center'; + URL.style.height = 'initial'; + URL.style.borderRadius = '2em'; + } +}; + +// 修复视频失效 +const FIX_VIDEO = () => { + const VIDEO_DIV = document.querySelector('[id^="video-a"]'); + if (VIDEO_DIV && VIDEO_DIV.innerHTML === '') { + VIDEO_DIV.style.zIndex = '9999'; + addVideos([document.querySelector('#url').value.trim()]); + } +} + +// 主函数 +const MAIN_HANDLER = () => { + IGNORE_EXCEPTION([ + ADD_IMGAGE_BACKGROUND, + ADD_UMBRELLA_BACKGROUND, + CHANGE_OHTER_UI, + REMOVE_README, + ADD_TIME_AND_IP, + FIX_VIDEO + ]); + document.body.removeAttribute('hidden'); +}; + +// 文档加载完毕执行主函数 +document.addEventListener('DOMContentLoaded', MAIN_HANDLER);