简书现在出了一个超恶心的需求,对过长的文章搞了一个遮罩,让用户主动点击才能展开全文,卧槽真的好烦啊,然后我以为是该网站为了减轻带宽搞的两次请求数据呢,结果一查network发现明明就一次请求~~~ 这非要让用户两次操作,烦死了~
ps:时间回到2022/7//22简书已经把这个恶心需求去掉了,估计也是意识到自己的错误~
然而办法总比困难多,这里我提供一个我利用油猴脚本进行扩展去广告,去点击展开全文的方法
油猴脚本插件,可以到这个网站进行下载,目前支持的浏览器也比较多chrome,safari等等都可以的,少数浏览器要求使用Violentmonkey,尤其移动端浏览器,清注意.
脚本工具使用方法咱就不说了,自行百度即可
我这里使用了别人写的一个脚本,在此基础上我扩展了一下里面的功能,主要让他把某平台(至于哪个平台,想必你向下拉已经发现一个展开全文了吧?)恶心的点击展开全文自动被去除掉,顺带着也把广告去掉了~
// ==UserScript==
// @name 阅读全文、自动展开全文、自动移除万恶弹框
// @namespace http://tampermonkey.net/
// @version 2.17.2
// @require https://greasyfork.org/scripts/415668-zmquery3-5-1/code/zmQuery351.js?version=866815
// @description 【非自动关注】【自用,长期维护】【功能有】1. 阅读全文网站支持:CSDN、github.io、xz577.com、iteye.com、720ui.com、cloud.tencent.com、新浪、头条、网易新闻、腾讯新闻、51CTO、知乎、果壳科技(移动版)、awesomes.cn、javascriptcn.com、人民日报(移动版)、凤凰网、虎扑移动版、百度经验、360文档(个人图书馆)、乐居买房(移动版)、电子发烧友网(PC、移动版)、悟空问答(PC、移动版)、百家号、百度文章、简书移动版、搜狐移动版、goodreads(PC、移动版)、百度文库(移动、PC版)、36氪移动版
// @author zhengmingliang
// @match https://*.csdn.net/*
// @match *://*.github.io/*
// @match *://*.jianshu.com/p/*
// @match *://m.sohu.com/a/*
// @match *://*.xz577.com/*
// @match *://*.javascriptcn.com/*
// @match *://*.baidu.com/*
// @exclude https://www.baidu.com/*
// @exclude *://tieba.baidu.com/*
// @exclude *://pan.baidu.com/*
// @match *://*.iteye.com/*
// @match *://*.720ui.com/*
// @match *://*.goodreads.com/book/show/*
// @match *://www.wukong.com/question/*
// @match *://cloud.tencent.com/*
// @match *://m.leju.com/*
// @match *://*.didispace.com/*
// @match *://*.sina.cn/*
// @match *://*.toutiao.com/*
// @match *://weibo.com/ttarticle/p/show*
// @match *://card.weibo.com/article/m/show/id/*
// @match *://3g.163.com/*
// @match *://*.*.163.com/news/*
// @match *://*.inews.qq.com/*
// @match *://*.36kr.com/p/*
// @match *://*.elecfans.com/*
// @match *://inews.qq.com/*
// @match *://xw.qq.com/*
// @match *://blog.51cto.com/*
// @match *://*.zhihu.com/question/*
// @match *://*.guokr.com/*
// @match *://*.awesomes.cn/*
// @match *://*.javazhiyin.com/*
// @match *://m.hupu.com/bbs/*
// @match *://wap.peopleapp.com/article/*
// @match *://jingyan.baidu.com/article/*
// @match *://*.ifeng.com/c/*
// @match *://*.360doc.com/content/*
// @match *://www.hi-linux.com/posts/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
/**
* 阅读全文 规则1(openwrite.cn 插件规则)
* @param readMoreSelector
* @param contentSelector
*/
function readAllRule1(readMoreSelector, contentSelector,isCurrent) {
if ($$$(readMoreSelector).length > 0) {
console.log("检测到有阅读全文关注限制。。。。")
// 移除阅读全文
if(isCurrent){
$$$(readMoreSelector).remove();
}else {
$$$(readMoreSelector).parent().remove();
}
// 使滚动条可见
// $$$("#article_content").css('overflow','auto')
// 优化后:直接将style置为空
console.log("style:%s", $$$(contentSelector).prop('style'))
$$$(contentSelector).prop('style', '')
$$$(contentSelector).attr('style', '')
$$$(contentSelector).css('max-height', 'none')
$$$(contentSelector).css('height', 'auto')
$$$(contentSelector).css('overflow', 'visible')
console.log("已解除阅读全文关注限制。。。。")
}
}
/**
* 阅读全文 规则1(openwrite.cn 插件规则)
* @param readMoreSelector
* @param contentSelector
*/
function readAllRule1ByOrigin(readMoreSelector, contentSelector,removeCurrent) {
var dom;
var parentElement, contentElement;
if (readMoreSelector.startsWith("#")) {
dom = document.getElementById(readMoreSelector.substring(1))
parentElement = removeCurrent ? dom : dom.parentElement;
} else if (readMoreSelector.startsWith(".")) {
dom = document.getElementsByClassName(readMoreSelector.substring(1))
if (dom.length > 0) {
parentElement = removeCurrent ? dom : dom[0].parentElement;
}
} else {
dom = document.getElementsByTagName(readMoreSelector)
parentElement = document.getElementsByClassName(readMoreSelector)[0].parentElement;
}
if (contentSelector.startsWith("#")) {
contentElement = document.getElementById(contentSelector.substring(1))
contentElement.style = ''
} else if (contentSelector.startsWith(".")) {
contentElement = document.getElementsByClassName(contentSelector.substring(1))
contentElement[0].style = ''
} else {
contentElement = document.getElementsByTagName(contentSelector)
contentElement[0].style = ''
}
console.log(111)
parentElement.parentElement.removeChild(parentElement);
}
/**
* 规则2:移除指定标签的某个class样式
* @param readMoreSelector
* @param removeSelector
* @param removeClass
*/
function readAllRule2(readMoreSelector, removeSelector, removeClass) {
if ($$$(readMoreSelector).length > 0) {
console.log("检测到有阅读全文关注限制。。。。")
// 移除阅读全文
$$$(readMoreSelector).remove();
// 使滚动条可见
// $$$("#article_content").css('overflow','auto')
}
if($$$(removeSelector).length > 0){
// 优化后:直接将style置为空
$$$(removeSelector).removeClass(removeClass)
console.log("已解除阅读全文关注限制。。。。")
}
}
/**
* 直接点击展开
* @param clickSelector
*/
function readAllRule3(clickSelector) {
var selector = $$$(clickSelector);
if (!selector) {
selector = jQuery(clickSelector);
}
if (selector.length > 0) {
console.log("检测到有阅读全文关注限制。。。。")
// 点击展开
selector.trigger("click")
console.log("已解除阅读全文关注限制。。。。")
}
}
/**
* 使用openwrite.cn策略的个人博客或其他使用类似的规则
*/
function readAllRule4(removeSelector) {
console.log("检测到有阅读全文关注限制。。。。")
// 移除阅读全文
$$$(removeSelector).parent().remove();
var zIndexArray = [];
var parentSelector = "div[style]"
if ($$$("article[style]").length > 0) {
parentSelector = "article[style]"
}
var flag = false
//存放只有height属性的节点
let heightArray = [];
findElements();
if (flag) {
console.log("已解除阅读全文关注限制。。。")
} else {
if (parentSelector == "div[style]" && heightArray.length == 1) {
heightArray[0].prop("style", "")
console.log("已解除阅读全文关注限制。。。。")
} else {
parentSelector = "div[style]"
heightArray = [];
findElements();
if (heightArray.length == 1) {
heightArray[0].prop("style", "")
console.log("已解除阅读全文关注限制。。。。。")
}
}
}
function findElements() {
$$$(parentSelector).each(function (index) {
var attr = $$$(this).attr('style');
if (attr.indexOf("overflow") != -1 && attr.indexOf("height") != -1) {
var overflow = $$$(this).css("overflow");
if ('hidden' == overflow) {
$$$(this).prop("style", "")
flag = true
}
} else if (attr.indexOf("height") != -1) {
console.log("index:", index, $$$(this))
heightArray.push($$$(this))
}
let text = $$$(this).text();
if (attr.indexOf("z-index") != -1 && (text.indexOf("首次访问") != -1 || text.indexOf("人机检测") != -1)) {
let zIndex = $$$(this).css("z-index");
console.log("zIndex:", zIndex)
let lastDiv = $$$("div[style]").filter(function () {
return $$$(this).attr('style').indexOf("z-index") != -1 && $$$(this).css("z-index") == zIndex - 1
})
console.log("lastDiv:", lastDiv)
if (lastDiv && lastDiv.length > 0) {
lastDiv.remove();
}
}
})
}
}
/**
* java学习 javazhiyin.com
*/
function removeFirstLayer() {
if ($$$(".layui-layer-page").length > 0) {
var text = $$$(".layui-layer-page").text();
if (text.indexOf('首次访问') != -1 || text.indexOf('人机识别')) {
}
$$$(".layui-layer-page").remove();
$$$(".layui-layer-shade").remove();
}
$$$("div[index]")
}
/**
* 对layui或layer 样式进行重写,使其弹框进行隐藏
*/
function addLayerCssStyle() {
$$$("style").get(0).append(".layui-layer-shade{display:none !important} .layui-layer-page{display:none !important}")
}
function addLayerCssStyle2() {
$$$("style").get(0).append(".layer-main{display:none !important}")
}
/**
* 对class 样式进行重写,使滚动条显示
*/
function addOverflowCssStyle(cssSelector) {
console.log("style:%s", $$$(cssSelector).prop('style'))
$$$(cssSelector).prop('style', '')
$$$(cssSelector).attr('style', '')
$$$(cssSelector).css('max-height', 'none')
$$$(cssSelector).css('height', 'auto')
$$$(cssSelector).css('overflow', 'visible')
}
/**
* 对class 样式进行重写
*/
function addDisplayStyle(cssSelector) {
$$$(cssSelector).css("display","none");
$$$(cssSelector).attr("style","display:none");
}
function addDisplayCssStyle() {
$$$("style").get(0).append("article{opacity: 1 !important;display: block !important;}" +
"#menu li{opacity: 1;display: block;}")
}
function removeAlertRule1() {
$$$("div[style]").each(function (index) {
let attr = $$$(this).attr('style');
let text = $$$(this).text();
if (attr.indexOf("z-index") != -1 && (text.indexOf("首次访问") != -1 || text.indexOf("人机检测") != -1)) {
let zIndex = $$$(this).css("z-index");
console.log("zIndex:", zIndex)
let lastDiv = $$$("div[style]").filter(function () {
return $$$(this).attr('style').indexOf("z-index") != -1 && $$$(this).css("z-index") == zIndex - 1
})
console.log("lastDiv:", lastDiv)
if (lastDiv && lastDiv.length > 0) {
lastDiv.remove();
}
$$$(this).remove();
$$$('body').css("overflow", 'auto');
}
})
}
/**
* 公共阅读全文规则1: 查找当前页面所有div接单,判断其style属性是否包含特征值
*/
function commonReadAllRule1() {
$$$("div").each(function (index) {
let attr = $$$(this).attr('style');
if(attr){
if (attr.indexOf("height") != -1 && attr.indexOf("overflow") != -1 && attr.indexOf("hidden") != -1) {
let id = $$$(this).attr('id');
let cls = $$$(this).attr('class');
let founded = false;
if(id){
console.log("检测到隐藏了全文的id:%s",id)
founded = true
}
if(cls){
console.log("检测到隐藏了全文的class:%s",cls)
founded = true
}
if(founded){
$$$(this).prop('style','')
$$$(this).attr('style','')
}
}
}
})
}
/**
* 公共移除dom节点
*/
function commonRemoveRules1(selectors,isRemoveParent) {
if ('string' == typeof (selectors)) {
return commonRemoveRule1(selectors,isRemoveParent)
}else {
for (let index in selectors) {
commonRemoveRule1(selectors[index],isRemoveParent)
}
}
}
/**
* 公共查找节点名称
*/
function commonFindRules1(keys) {
let split = keys.split(",");
let selector = $$$("div").filter(function (){
let text = $$$(this).text();
let flag = false;
for (let i in split) {
flag = text.indexOf(split[i]) && flag ;
}
return flag && $$$(this).children().length == 0
})
let id = selector.attr("id");
if(id){
return "#"+id;
}
let cls = selector.attr("class");
if(cls){
return "."+cls;
}
return selector;
}
function commonRemoveRule1(selector,isRemoveParent) {
var $selector = $$$(selector);
if($selector.length > 0){
if(isRemoveParent){
$selector.parent().remove();
}else {
$selector.remove();
}
}
}
/**
* 公共隐藏
* @param selectors
* @param isRemoveParent
*/
function commonHideRule1(selectors) {
var selectorArray = selectors.split(",");
for (let index in selectorArray) {
if ($$$("style").length > 0) {
$$$("style").get(0).append(selectorArray[index] + "{display:none !important}");
}else {
$$$("header").append("<style></style>");
$$$("style").get(0).append(selectorArray[index] + "{display:none !important}");
}
}
}
var $$$ = $ || window._$ || zmQuery;
var href = window.location.href
function intervalReadAllRule2(checkSelector, removeSelector, removeClass) {
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(checkSelector).length > 0) {
readAllRule2(checkSelector, removeSelector, removeClass)
clearInterval(interval)
}
}, 1000)
}
// csdn
if (href.indexOf('csdn') != -1) {
console.log("检测到CSDN。。。。")
// 已登录
readAllRule1("#btn-readmore-zk", "#article_content")
// 未登录
readAllRule1(".btn-readmore", "#article_content")
// 移动端处理
readAllRule1(".btn_mod", ".article_content")
$$$("style").get(0).append(".login-box{display:none !important} \r\n .login-mark{display:none !important}");
} else if (href.indexOf('github.io') != -1) { //hoxis.github.io
console.log("检测到github.io。。。。")
readAllRule1("#read-more-btn", "#container")
addDisplayCssStyle();
} else if (href.indexOf('jianshu.com') != -1) { //jianshu.com
let interval = setInterval(function () {
console.log("轮训检测...")
let count=0
if ($$$(".ant-btn").length > 0) {
console.log("展开全文")
//向按钮派发事件
$$$(".ant-btn").click()
clearInterval(interval)
}
count++
if(count>10){
clearInterval(interval)
}
}, 1000)
let guanggaocount=0
let interval2 = setInterval(function () {
console.log("轮训检测...")
if ($$$(".logo-close-img").length > 0) {
console.log("广告关闭")
//向按钮派发事件
$$$(".logo-close-img").click()
}
guanggaocount++
if(guanggaocount>10){
clearInterval(interval2)
}
}, 1000)
commonHideRule1(".download-app-guidance,.call-app-btn,#jianshu-header")
readAllRule1(".close-collapse-btn", ".collapse-free-content",)
} else if (href.indexOf('m.sohu.com') != -1) { //m.sohu.com
console.log("m.sohu.com。。。。")
commonHideRule1(".lookall-box")
readAllRule2("#artLookAll", ".hidden-content","hide")
$$$(".content-image").each(function () {
var src = $$$(this).data("src");
$$$(this).attr("src",src);
$$$(this).attr("data-lazy-load-completed","1");
})
} else if (href.indexOf('jingyan.baidu.com') != -1) { //百度经验
console.log("检测到百度经验。。。。")
readAllRule2(".read-whole-mask", ".exp-content-container.fold","fold")
} else if (href.indexOf('xz577') != -1) { //www.xz577.com
console.log("检测到xz577。。。。")
readAllRule1(".m-zk", "#mewsmian")
// Your code here...
} else if (href.indexOf('cloud.tencent.com') != -1) { //cloud.tencent.com
console.log("检测到tencent。。。。")
let interval = setInterval(function () {
if ($$$(".com-markdown-collpase-hide").length > 0) {
readAllRule1(".com-markdown-collpase-toggle", ".com-markdown-collpase-main", true)
readAllRule2(".com-markdown-collpase-toggle", ".com-markdown-collpase-hide", "com-markdown-collpase-hide")
clearInterval(interval)
}
}, 1000)
// Your code here...
} else if (href.indexOf('iteye.com') != -1) { //iteye.com
console.log("检测到iteye.com。。。。")
readAllRule3("#btn-readmore")
// Your code here...
} else if (href.indexOf('720ui.com') != -1) { // 720ui.com
console.log("检测到720ui.com。。。。")
readAllRule1("#read-more-btn", "#main")
} else if (href.indexOf('360doc.com') != -1) { // 360doc
console.log("检测到360doc.com。。。。")
addOverflowCssStyle(".article_container")
addDisplayStyle(".article_showall")
} else if (href.indexOf('m.leju.com') != -1) { // 360doc
console.log("检测到m.leju.com。。。。")
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".ztt_more").length > 0) {
readAllRule1(".ztt_more", ".ztt_outer",true)
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('card.weibo.com') != -1) { // 微博
console.log("检测到weibo.com。。。。")
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".f-art-opt").length > 0) {
readAllRule1(".f-art-opt", ".f-art",true)
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('weibo.com') != -1) { // 微博
console.log("检测到weibo.com。。。。")
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".artical_add_box").length > 0) {
readAllRule1(".artical_add_box", ".WB_editor_iframe_new",true)
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('sina.cn') != -1) { // k.sina.cn
console.log("检测到sina.cn。。。。")
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".unfold-btn1").length > 0) {
readAllRule1ByOrigin(".unfold-btn1", ".main-body")
clearInterval(interval)
}else if ($$$(".ztt_more").length > 0) {
readAllRule1ByOrigin(".ztt_more", ".ztt_outer",true)
clearInterval(interval)
}else if ($$$(".look_more_a").length > 0) {
readAllRule1ByOrigin("#artFoldBox", ".s_card z_c1",true)
clearInterval(interval)
}
commonRemoveRules1(".callApp_fl_btn")
}, 1000)
} else if (href.indexOf('toutiao') != -1) { // toutiao.com
console.log("检测到toutiao。。。。")
// 循环检测
intervalReadAllRule2(".fold-btn", ".fold-btn-content", "fold-btn-content-fold");
// document.removeEventListener('click',getEventListeners($$$(document).get(0)).click[0].listener)
} else if (href.indexOf('3g.163.com') != -1) { // 3g.163.com
console.log("检测到163.com。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".expand_more").length > 0) {
readAllRule1(".expand_more", "article")
clearInterval(interval)
}
$$$(".article_comment").css("display","block")
}, 1000)
} else if (href.indexOf('baijiahao') != -1|| href.indexOf('mbd.baidu.com') != -1) { // 百度文章
console.log("检测到百家号。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".oPadding").length > 0) {
readAllRule1(".oPadding", ".mainContent",true)
$$$(".scrollHide").removeClass("scrollHide");
clearInterval(interval)
}
if ($$$(".height-fold").length > 0) {
readAllRule1(".height-fold", ".dynamic-item",true)
$$$(".scrollHide").removeClass("scrollHide");
clearInterval(interval)
}
}, 1000)
addLayerCssStyle2();
} else if (href.indexOf('wenku.baidu.com') != -1) { // 百度文库PC版
console.log("检测到百度文库。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$("#reader-container").length > 0) {
$$$("#reader-container").css("height","fit-content");
commonHideRule1(".try-end-fold-page")
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('wk.baidu.com') != -1) { // 百度文库移动版
console.log("检测到百度文库。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".fold-pager").length > 0) {
$$$("#reader-container").css("height","fit-content");
commonHideRule1(".fold-pager")
$$$(".reader-wrap").css('height', 'auto')
$$$("#view-app").css('max-height', '')
$$$(".try-end-fold-page").css('display', 'block')
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('www.elecfans.com') != -1) { // elecfans.com
console.log("检测到电子发烧友。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".seeHide").length > 0) {
readAllRule1(".seeHide", ".simditor-body", true)
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('m.elecfans.com') != -1) { // elecfans.com
console.log("检测到电子发烧友。。。。")
// 循环检测
let
interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".see_more_arc").length > 0) {
readAllRule2(".see_more_arc", ".limit_height", "limit_height")
clearInterval(interval)
commonRemoveRule1(".open_app",false)
commonRemoveRule1(".open_app_arc",false)
commonRemoveRule1(".open_app_btn",false)
}
}, 1000)
} else if (href.indexOf('wukong.com') != -1) { // elecfans.com
console.log("检测到悟空问答。。。。")
// 循环检测
let
interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".fold").length > 0) {
readAllRule2(".expand-bottom", ".fold", "fold")
}
}, 1000)
let interval2 = setInterval(function () {
console.log("轮训检测...")
if ($$$(".read-mask").length > 0) {
readAllRule1(".read-mask", ".content", true)
clearInterval(interval2)
commonRemoveRule1(".btn",false)
commonRemoveRule1(".download",false)
}
}, 1000)
} else if (href.indexOf('peopleapp.com') != -1) { // peopleapp.com
console.log("检测到人民日報。。。。")
let count = 0;
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$(".read-more-mask").length > 0) {
readAllRule1(".read-more-mask", ".has-more-high",)
$$$("#header").remove()
if(count++ > 10){
clearInterval(interval)
}
}
}, 1000)
} else if (href.indexOf('ifeng.com') != -1) { // ifeng.com
console.log("检测到鳳凰网。。。。")
// 循环检测
let interval = setInterval(function () {
console.log("轮训检测...")
if ($$$("div[class^=tip-]").length > 0) {
// readAllRule4(, "div[class^=main_content-]")
commonRemoveRules1(["div[class^=tip-]",".link-1xGgkMtk"])
commonReadAllRule1();
clearInterval(interval)
}
}, 1000)
} else if (href.indexOf('awesomes.cn') != -1) { // awesomes.com
console.log("检测到awesomes.cn。。。。")
// 循环检测
if ($$$(".read_more_mask").length > 0) {
readAllRule1(".read_more_mask", ".content")
}
} else if (href.indexOf('javascriptcn.com') != -1) { // javascriptcn.com
console.log("检测到javascriptcn.com。。。。")
// 循环检测
if ($$$(".read_more_mask").length > 0) {
readAllRule1(".read_more_mask", ".markdown-body")
}
} else if (href.indexOf('hupu.com') != -1) { // hupu.com
console.log("hupu.com。。。。")
// 循环检测
let interval = setInterval(function (){
console.log("轮训检测...")
if ($$$(".open-btn").length > 0) {
readAllRule1(".open-btn", "#bbs-detail-wrap")
clearInterval(interval)
}
},1000)
} else if (href.indexOf('xw.qq.com') != -1) { // xw.qq.com
console.log("检测到xw.qq.com。。。。")
// 循环检测
intervalReadAllRule2("div[aria-label]", "#article_body", "jsx-2375966888");
$$$("#article_body").prop("style","margin:0 0.18rem; position:relative")
} else if (href.indexOf('inews.qq.com') != -1) { // inews.qq.com
console.log("检测到inews.qq.com。。。。")
// 循环检测
let interval = setInterval(function (){
console.log("轮训检测...")
if($$$("._1mAOD6Nkgp2wM7xlGCHeNi").length > 0){
commonRemoveRules1(["._1mAOD6Nkgp2wM7xlGCHeNi","._1GTaS1LTuTrKnZ-oQ6KFRG"],true)
commonReadAllRule1()
clearInterval(interval)
}
},1000)
} else if (href.indexOf('goodreads.com') != -1) { // goodreads.com
console.log("检测到goodreads.com。。。。")
// 循环检测
let interval = setInterval(function (){
console.log("轮训检测...")
if($$$("a[onclick^=swapContent").length > 0){
// PC 版本
$$$(".readable > span:nth-child(2)").attr("style","display:block")
// 移动版本
$$$(".bookReviewBody > span:nth-child(2)").attr("style","display:block")
$$$("a[onclick^=swapContent").attr("style","display:none")
clearInterval(interval)
}
},1000)
} else if (href.indexOf('51cto.com') != -1) { // blog.51cto.com
console.log("检测到blog.51cto.com。。。。")
// 循环检测
/*$$$(document).scroll(function (){
let count = 0;
console.log("轮训检测")
let interval = setInterval(function (){
if($$$("#login_iframe_mask").length > 0){
console.log("已清理登录弹框")
$$$("#login_iframe_mask").remove();
clearInterval(interval)
}
if( count ++ > 10){
count = 0;
clearInterval(interval)
}
},1000)
})*/
// modify by zml 2020年10月31日 23:07:07 将原来监听是否有元素方式改为页面中添加css样式的方式来更好的解决弹框不停弹出的问题
$$$("style").get(0).append("#login_iframe_mask{display:none}");
} else if (href.indexOf('zhihu.com') != -1 && document.documentElement.clientWidth<768) { // blog.51cto.com
console.log("检测到zhihu.com。。。。")
let count = 0;
let interval = setInterval(function (){
if(".ModalWrap-body".length > 0){
$$$(".ModalWrap-body").prop("style","").removeClass("ModalWrap-body")
}
if(".is-collapsed".length > 0){
$$$(".is-collapsed").removeClass("is-collapsed");
}
if($$$(".RichContent-inner").length > 0){
// $$$(".RichContent-inner").prop("style","").removeClass("RichContent-inner--collapsed")
addOverflowCssStyle(".RichContent-inner--collapsed")
addOverflowCssStyle(".RichContent--unescapable")
addOverflowCssStyle(".is-collapsed")
}
if ($$$(".expandButton").length > 0) {
console.log("移除阅读全文")
// $$$(".expandButton").remove()
addDisplayStyle(".expandButton")
}
if ($$$(".ContentItem-expandButton").length > 0) {
console.log("移除阅读全文")
// $$$(".ContentItem-expandButton").remove()
addDisplayStyle(".ContentItem-expandButton")
}
if(count++ > 100){
clearInterval(interval);
}
},100)
$$$("style").get(0).append(".ModalWrap{display:none}");
} else if (href.indexOf('36kr.com') != -1 && document.documentElement.clientWidth<768) { // 36氪
console.log("检测到36kr.com。。。。")
let interval = setInterval(function (){
if($$$(".tips-mask").length > 0){
commonHideRule1(".tips-mask");
commonHideRule1(".tips-content");
commonHideRule1(".swiper-wrapper");
$$$("#body-content").removeClass(" no-open")
$$$("body").attr("style","")
commonHideRule1(".article-goapp");
clearInterval(interval);
}
},100)
} else if (href.indexOf('m.guokr.com') != -1) { // m.guokr.com
console.log("检测到m.guokr.com。。。。")
//let height = $$$(".styled__ArticleContent-sc0ctyfcr-4").position().top-$$$(".styled__ArticleContent-sc0ctyfcr-4").children().position().top
//$$$(".styled__ArticleContent-sc0ctyfcr-4").css("height",height);
$$$(".jYkhp").css("max-height","100%");
$$$(".jYkhp").css("overflow","auto");
$$$(".styled__Button-sc-1ctyfcr-7").parent().remove()
$$$(".gJghO").css("display","none")// 移除底部APP横幅广告
} else if ($$$("#read-more-btn").length > 0) {
console.log("检测到可能使用了openwrite推广工具。。。。")
readAllRule4("#read-more-btn");
} else if ($$$(".mask").length > 0 && $$$(".info").length > 0) { // cmsblogs.com
console.log("检测到%s。。。。", href)
readAllRule4(".info");
} else if (href.indexOf("iocoder") != -1) {
setInterval(removeAlertRule1(), 10000);
} else if (href.indexOf("javazhiyin") != -1) {
addLayerCssStyle();
// 每隔10s移除弹出的关注检测弹框
setInterval(removeFirstLayer(), 10000)
} else {
}
})();
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
在应用开发中,有时候我们需要获取系统的设备信息,用于数据上报和行为分析。那在鸿蒙系统中,我们应该怎么去获取设备的系统信息呢,比如说获取手机的系统版本号、手机的制造商、手机型号等数据。1、获取方式这里分为两种情况,一种是设备信息的获取,一种是系统信息的获取。1.1、获取设备信息获取设备信息,鸿蒙的SDK包为我们提供了DeviceInfo类,通过该类的一些静态方法,可以获取设备信息,DeviceInfo类的包路径为:ohos.system.DeviceInfo.具体的方法如下:ModifierandTypeMethodDescriptionstatic StringgetAbiList()Obt
//1.验证返回状态码是否是200pm.test("Statuscodeis200",function(){pm.response.to.have.status(200);});//2.验证返回body内是否含有某个值pm.test("Bodymatchesstring",function(){pm.expect(pm.response.text()).to.include("string_you_want_to_search");});//3.验证某个返回值是否是100pm.test("Yourtestname",function(){varjsonData=pm.response.json
作为新的阿里云用户,您可以50免费试用多种优惠,价值高达1,700美元(或8,500美元)。这将让您了解和体验阿里云平台上提供的一系列产品和服务。如果您以个人身份注册免费试用,您将获得价值1,700美元的优惠。但是,如果您是注册公司,您可以选择企业免费试用,提交基本信息通过企业实名注册验证,即可开始价值$8,500的免费试用!本教程介绍了如何设置您的帐户并使用您的免费试用版。关于免费试用在我们开始此试用之前,您还必须遵守以下条款和条件才能访问您的免费试用:只有在一年内创建的账户才有资格获得阿里云免费试用。通过此免费试用优惠,用户可以免费试用免费试用活动页面上列出的每种产品一次。如果您有多个帐
有没有一种简单的方法可以判断ruby脚本是否已经在运行,然后适本地处理它?例如:我有一个名为really_long_script.rb的脚本。我让它每5分钟运行一次。当它运行时,我想看看之前运行的是否还在运行,然后停止第二个脚本的执行。有什么想法吗? 最佳答案 ps是一种非常糟糕的方法,并且可能会出现竞争条件。传统的Unix/Linux方法是将PID写入文件(通常在/var/run中)并在启动时检查该文件是否存在。例如pid文件位于/var/run/myscript.pid然后你会在运行程序之前检查它是否存在。有一些技巧可以避免
我正在开发一个Ruby脚本,需要在没有Ruby解释器的情况下部署到系统上。它将需要在使用ELF格式的FreeBSD系统上运行。我知道有一个ruby2exe项目可以编译在Windows上运行的ruby脚本,但是在其他操作系统上这样做容易吗?甚至可能吗? 最佳答案 您是否检查过Rubinius或JRuby是否允许您预编译您的代码? 关于ruby-ruby脚本可以预编译成二进制文件吗?,我们在StackOverflow上找到一个类似的问题: https://
我想用sunspot重现以下原始solr查询q=exact_term_text:fooORterm_textv:foo*ORalternate_text:bar*但我无法通过标准的太阳黑子界面理解这是否可能以及如何实现,因为看起来:fulltext方法似乎不接受多个文本/搜索字段参数我不知道将什么参数作为第一个参数传递给fulltext,就好像我通过了"foo"或"bar"结果不匹配如果我传递一个空参数,我得到一个q=*:*范围过滤器(例如with(:term).starting_with('foo*')(顾名思义)作为过滤器查询应用,因此不参与评分。似乎可以手动编写字符串(或者可能使
我的ruby脚本从命令行参数获取某些输入。它检查是否缺少任何命令行参数,然后提示用户输入。但是我无法使用gets从用户那里获得输入。示例代码:test.rbname=""ARGV.eachdo|a|ifa.include?('-n')name=aputs"Argument:#{a}"endendifname==""puts"entername:"name=getsputsnameend运行脚本:rubytest.rbraghav-k错误结果:test.rb:6:in`gets':Nosuchfileordirectory-raghav-k(Errno::ENOENT)fromtes