知乎去首页加载广告V0.5
// ==UserScript==
// @name 知乎去首页加载广告V0.5
// @namespace http://tampermonkey.net/
// @version 0.5
// @description try to take over the world!
// @author You
// @match https://www.zhihu.com/
// @match https://www.zhihu.com/search*
// @icon https://www.google.com/s2/favicons?domain=zhihu.com
// @grant none
// @run-at document-start
// ==/UserScript==
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.innerText='.SearchBar-askButton{background-color:white !important;border-width: 0;}.SearchBar button{color: #28AEFF !important;}.SearchTabs-actions .Tabs-link{color: black !important;}.AppHeader-inner .SearchBar-input{border-width: 2px;border-style: solid;border-color: #28AEFF;}.AppHeader-inner a{color:white !important}.AppHeader-inner button{color:white}.Avatar{border-radius: 50%;}.GlobalSideBar-category >a{display:none}.TopstoryPageHeader-main a{color:white !important}.App-main >.Topstory >div{display:none}.Topstory >.Topstory-container{display: flex !important;}.App-main{overflow-x: hidden;}.Sticky .Pc-card{display:none;}header{background-color: #28aeff !important; color: white !important;}header div {border: 0px solid rgb(108, 67, 226) !important;}header .is-active{color: white !important;}'
head.appendChild(style);
let oldfetch=fetch
function newobj(){}
function fuckfetch(...bianliang){
return new Promise(function(resolve, reject){
oldfetch(...bianliang).then(function(response) {
let handler = {
get: function(target, prop, receiver) {
if(typeof Reflect.get(target,prop)==='function')
{
if(Reflect.get(target,prop+'proxy')===undefined)
{
target[prop+'proxy']=(...funcargs)=> {
let result=target[prop].call(target,...funcargs)
if(bianliang.length!==0&&bianliang[0].indexOf('/api/v3/feed/topstory/recommend')!==-1&&prop==='json'){
return new Promise(function(resolve, reject){
result.then(
function(data){
console.log('bianliang',bianliang)
let retobj={
data:[],
fresh_text:data.fresh_text,
paging:data.paging,
}
for(let index=0;index<data.data.length;index++){
if(data.data[index].ad===undefined){
retobj.data.push(data.data[index])
}
}
resolve(retobj)
}
)
})
}
console.log('fetchfunction',prop,funcargs,result)
return result
}
}
return Reflect.get(target,prop+'proxy')
}
return Reflect.get(target, prop);
},
set(target, prop, value) {
return Reflect.set(target, prop, value);
},
};
let proxy=new Proxy(response, handler)
resolve(proxy)
})
});
}
window.fetch=fuckfetch
window.onload=function(){
document.querySelector('.Pc-feedAd-container').parentElement.style.display='none'
/* let divlist=document.querySelectorAll('.Topstory >div')
for(let index=0;index<divlist.length;index++){
let item=divlist[index];
if(item.className.indexOf('Top')===-1){
item.remove()
}
}*/
}
/*
let divlist=document.querySelectorAll('.Topstory >div')
for(let index=0;index<divlist.length;index++){
let item=divlist[index];
if(item.className.indexOf('Top')===-1){
item.remove()
}
}*/