Greasy Fork is available in English.
更佳的浏览体验,更快获得微信文章封面图与文章摘要以及更多功能
当前为
// ==UserScript== // @name 微信文章浏览功能拓展 // @namespace https://blog.csdn.net/Huuc6 // @version 1.0 // @description 更佳的浏览体验,更快获得微信文章封面图与文章摘要以及更多功能 // @author huuc // @match *://mp.weixin.qq.com/s* // @icon https://gitee.com/ziuc/utool-filebed/raw/master/20210514-231824-0795.png // @grant GM_getValue // @grant GM_setValue // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js // @license GPL-2.0 // ==/UserScript== (function() { 'use strict'; let state= { url_state : true, // 是否启用封面图链接功能 openNewWindow_state : true, // 是否在新窗口打开封面图链接 datetype_state : true, // 是否修改默认时间显示模式 summary_state : true, // 是否启用读取摘要功能 clipboard_state : true, // 是否启用点击摘要复制到剪切板功能 preview_state : true, // 是否启用封面图预览功能 summary_show_state : true, // 是否默认显示摘要 eye_protection_state : false, // 是否启用护眼模式 recommend_state : false, // 是否显示引导关注栏 config_state : true // 是否默认显示设置侧边栏 } // 设置框 const configBox = "<div id='config_window' style='position:fixed;z-index:999999;opacity:0.3;cursor:pointer;top:10%;left:0px;'>"+ "<div id='config_url' title='点击跳转封面链接' style='font-size:13px;padding:8px 3px;color:#FFF;background-color:#25AE84;'>封面链接</div>"+ "<div id='config_summary' title='可前往源码修改是否默认显示' style='font-size:13px;padding:8px 3px;color:#FFF;background-color:#25ae84;'>文章摘要</div>"+ "<div id='config_eyeProtect' title='双击关闭' style='font-size:13px;padding:8px 3px;color:#FFF;background-color:#25ae84;'>护眼:ON</div>"+ "<div id='config_info' title='Have a good day :D' style='font-size:13px;padding:8px 3px;color:#8d8d8d;'></div>"+ "</div>"; $('body').append(configBox); // 给ESC按键添加事件:按下出现设置框 $(document).keyup(function (event) { switch (event.keyCode) { case 27: $('#config_window').toggle(); } }); // 给设置窗口添加效果 移入透明度加深 移出透明度变浅 $("#config_window").mouseenter(function(){ $("#config_window").css("opacity","1.0"); }); $("#config_window").mouseleave(function(){ $("#config_window").css("opacity","0.3"); }); // 时间格式 $('#config_datetype').click(function (){ }) // 文章摘要 $('#config_summary').click(function (){ $('#summary').toggle('fast'); state.summary_state=false; }) // 封面图 if(state.url_state===true) { let linkReg = /msg_cdn_url = "(.*)"/ig; let data = $("*").html(); let url = linkReg.exec(data); let trueurl = url[1]; // 跳转 $('#config_url').click(function () { if(state.openNewWindow_state===true){ window.open(trueurl) } else {window.location.href=trueurl} }) // 预览封面图功能 if (state.preview_state === true) { // 引入封面图并设置默认隐藏 $('#profileBt').after('<img id="picture_url"></img>') $('#picture_url').attr("src", trueurl) $('#picture_url').css({"zoom": "35%", "position": "absolute","left":"45px","border-radius":"8px"}) $('#picture_url').hide() // 加入鼠标事件 实现预览功能 $('#profileBt').mouseenter(function () { $('#picture_url').toggle() $('#picture_url').css({"zoom": "52%", "opacity": "0.8"}) }) $('#profileBt').mouseleave(function () { $('#picture_url').toggle() }) } } // 摘要 if(state.summary_state===true) { let meta = $('meta[name="description"]'); let contents = meta[0].content; // 点击摘要复制到剪切板 if(state.clipboard_state===true){ let clipboard = new ClipboardJS('.btn'); // 要使用 clipboard.js 需要声明一个clipboard实例 } $('#meta_content').append('afterend','<div id="summary" class="btn" data-clipboard-text="#" style="color: #b2b2b2; border-radius: 5px"></div>'); $('#summary').html(contents); $('#summary').attr("data-clipboard-text",contents); $('#summary').attr("title","点击复制到剪切板"); // 给摘要设置样式与效果事件 $('#summary').css({"text-align":"left","font-size":"15px"}) // 设置摘要左居中 $('#summary').mouseenter(function (){ $('#summary').css('color','#383838') }) $('#summary').mouseleave(function (){ $('#summary').css('color','#b2b2b2') }) } // 设置摘要是否默认显示 if(state.summary_show_state===false) { $('#summary').hide(); // 设置默认隐藏摘要 } //修改时间格式 if(state.datetype_state===true) { let linkReg = /",i="(\d{4}-\d{1,2}-\d{1,2})";/g; let data = $("*").html(); let date = linkReg.exec(data); let before_date=$('#publish_time').text() $('#publish_time').text(date[1]); } //隐藏引导关注栏 if (state.recommend_state!==true) { $('.qr_code_pc').hide(); } // 默认显示设置侧边栏 if(state.config_state===false){ $('#config_window').hide(); // 默认隐藏设置框 } // 护眼模式 if(state.eye_protection_state===true){ $('#page-content').css('background-color','#C7EDCC') $('#config_eyeProtect').dblclick(function (){ $('#page-content').css('background-color','white') $('#config_eyeProtect').text('护眼:OFF') $('#config_eyeProtect').attr('title','单击打开') }) $('#config_eyeProtect').click(function (){ $('#page-content').css('background-color','#C7EDCC') $('#config_eyeProtect').text('护眼:ON') $('#config_eyeProtect').attr('title','双击关闭') }) } else if(state.eye_protection_state===false){ $('#config_eyeProtect').hide(); } })();