Greasy Fork is available in English.
让你无弹窗、无限制的阅读经济学人。改编自Ligz的1.1脚本
当前为
// ==UserScript==
// @name 无限制阅读经济学人
// @namespace
// @version 2.1
// @description 让你无弹窗、无限制的阅读经济学人。改编自Ligz的1.1脚本
// @author August
// @match *.economist.com/*
// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// @grant none
// ==/UserScript==
$(function() {
'use strict';
console.log('the economist script run!')
let del = ['#_evidon_banner','#amp-regwall','#gpt-ad-slot-regwall','.related-articles','.layout-article-regwall','.ds-layout-grid.ds-layout-grid--edged.newsletter-signup']
let timer1 = setInterval(() => {
del.forEach(item => {
if ($(item)) {$(item).remove();}
})
}, 1000)
let postQuery = "#regwall__wrapper p.article__body-text";
let jsonData = '#__NEXT_DATA__'
let timer2 = setInterval(() => {
let postBody = $(postQuery)
let nextData = $(jsonData)
if(postBody.length && nextData.length){
//console.log(postBody)
//console.log(nextData)
let data = JSON.parse(nextData[0].text).props.pageProps.content.text
//console.log(data)
for(let i = postBody.length;i<data.length;i++){
//console.log(data[i])
let string = '';
switch(data[i].name){
case 'p':
switch(data[i].type){
case 'tag':
data[i].children.forEach(item => {
switch(item.type){
case 'tag':
item.children.forEach(each =>{
let attr = '';
for(let att in each.attribs){
attr += att + '=' + each.attribs[att];
}
//console.log(attr);
string +='<'+item.name+ attr +'>'+ each.data +'</'+item.name+'>';
})
break;
case 'text':
string += item.data;
break;
default:
break;
}
})
break;
default:
break;
}
break;
case 'figure':
break;
default:
break;
}
//console.log(string)
postBody.parent().append('<p class="article__body-text">'+string+'</p>');
}
clearInterval(timer1)
clearInterval(timer2)
}
}, 1000)
})();