CIFCOM跨境电商 CIFCOM跨境电商

当前位置: 首页 » 出海百科 »

闲鱼app广告

安装谷歌浏览器去广告插件

视频加载中...

若视频中方法行不通,请参照下文方法

大家在上网的时候最讨厌的应该就是那些乱七八糟的网页广告了吧。今天给用谷歌上网的用户介绍一下谷歌去广告插件,有兴趣的朋友可以试一试。

首先,我们要先去网上下载好这两个文件,注意别下老版本的,老版本的用不了。

然后我们打开谷歌浏览器,右上角三个点,依次选择更多工具、扩展程序。

然后打开右上角的开发者模式,把.crx格式的文件直接拖拽进去,并记录其ID

Windows+R键打开运行,输入gpedit.msc后按回车,调出策略器

选择计算机配置下的管理模板,右键选择添加删除模板

点击添加,将文件中.adm格式的文件添加进去

点击模板管理,找到经典管理模板,再找到Google并单击

在右侧找到扩展程序并打开,找到配置扩展程序安装白名单并双击。

点击已启用,然后点击显示,将我们之前记录的ID输入进去,点击确定即可。

关掉浏览器再重新打开,删掉之前安装的插件,再重新托进入一次即可完成安装

油猴脚本实现谷歌搜索去广告

实现效果

个人更喜欢用google进行搜索,然后抽空的时候可以看看百度热搜,来回切换总有点不方便,所以编写一个的油猴脚本,实现谷歌搜索去广告,然后右侧展示百度搜索结果和热搜,先看下使用前效果

脚本运行后的效果

api介绍

先放一个官方文档地址,下面介绍下这次用到的脚本Api

@match 脚本运行在哪个网页

例子:@match *

@grant 申请GM_*函数和unsafeWindow权限

例子:@grant GM_xmlhttpRequest 可以实现跨域请求,在访问谷歌页面的时候请求百度页面,然后将热搜缝合在右侧

@require 可以引用外部的js脚本

例子:@require 引入jquery脚本

分析

谷歌搜索页

访问网页,按f12打开控制台,发现广告在id为taw的div下面

右侧的内容在id为rhs的div下面,有时候不存在右侧内容,可以将热搜结果放在#rcnt下

百度搜索页

右侧的热搜是放在class为toplist1-tr*的下面,网页其实是把30条热搜全部加载完成之后,点击切换通过控制css display: none; 来显示和隐藏。所以可以通过正则 /<div class="toplist1-tr([\s\S])*?<\/div>/g 将他们全部取出来

顺便也可以把搜索的结果展示在右侧,通过 /<h3 class="c-title t t tts-title">/g 来获取所有结果。匹配之后发现一个issue,百度自家的搜索结果没匹配上,正好这些结果没啥用。

核心代码

在页面加载完成后执行脚本,获取百度结果,然后拼接,开始以为点击搜索是异步请求,结果是前后端不分离的,整个页面刷新,所以每次搜素后都会执行这个脚本,就不用hook一些点击事件、请求、dom发生变化之类的东西,执行就ok。

去除谷歌广告

function delGoogleAd() { $("#taw").remove(); $("#bottomads").remove();}

获取百度搜索结果

GM_xmlhttpRequest({ method: "get", url: "?wd=" + searchKey, onload: function (r) { console.log(r); }})完整代码

// ==UserScript==// @name test// @namespace @version 0.1// @description try to take over the world!// @author You// @match *// @grant GM_xmlhttpRequest// @require ==/UserScript==(function () { "use strict"; function delGoogleAd() { $("#taw").remove(); $("#bottomads").remove(); } async function addBdResult() { console.log($(`#tsf input`).value, $(`#tsf input.gLFyf.gsfi`).val()); const [str, hotRes] = await getBdResult($(`#tsf input.gLFyf.gsfi`).val()); // 处理百度热搜 const hotHtml = handleHot(hotRes); const rhs = $("#rhs"); if (rhs.length) { rhs.html(str).append(hotHtml); } else { $("#rcnt") .append(`<div id="rightBar" style="margin-left:20px;">${str}</div>`) .find("#rightBar") .append(hotHtml); } } async function getBdResult(searchKey) { return new Promise((reslove, reject) => { GM_xmlhttpRequest({ method: "get", url: "?wd=" + searchKey, onload: function (r) { if (r.status === 200 && r.readyState === 4) { //解析搜索结果 let resReg = /<h3 class="c-title t t tts-title">([\s\S])*?<\/h3>/g; let result = "", temp; while ((temp = resReg.exec(r.responseText)) != null) { result += temp[0]; } // console.log("result===>", result); let str = result .replace( /<h3 class="c-title t t tts-title">/g, `<h4 style="margin: 6px 0;">` ) .replace(/<\/h3>/g, "</h4>"); // 解析百度热搜 let hotReg = /<div class="toplist1-tr([\s\S])*?<\/div>/g; let hotRes = [], tempRes; while ((tempRes = hotReg.exec(r.responseText)) != null) { // console.log(tempRes); hotRes.push( tempRes[0].replace(`href="`, `href="`) ); } reslove([str, hotRes]); } else { reject(r.responseText); } }, }); }); } function handleHot(hotRes = []) { const hotPage1 = hotRes.splice(0, 15); const hotPage2 = hotRes; let toggleShow = true; return $( `<div><div id="toggle" style="cursor: pointer; margin-bottom: 10px;">切换</div></div>` ) .append(() => { return $( `<div id="page1" style="display: ${toggleShow ? "none" : ""}"><div/>` ).append(hotPage2.join("")); }) .append(() => { return $( `<div id="page2" style="display: ${toggleShow ? "" : "none"}"><div/>` ).append(hotPage1.join("")); }) .find("#toggle") .on("click", function () { toggleShow = !toggleShow; console.log($(this).next()); $(this) .next() .css("display", toggleShow ? "none" : "") .next() .css("display", toggleShow ? "" : "none"); }) .end(); } function hookListener() { let oldadd = EventTarget.prototype.addEventListener; EventTarget.prototype.addEventListener = function (...args) { console.log("addEventListener", this); oldadd.call(this, ...args); }; } // hookListener(); // $(()=>{ // }) delGoogleAd(); addBdResult();})();

浓眉大眼的也叛变了?教你清除Chrome的自带广告

[PConline 技巧]Chrome自诞生起,就一直以快速、简洁、干净著称。然而,Chrome的作风在最近似乎有了改变,这浓眉大眼的也叛变了,在主界面加入了广告!有朋友发现,当开启Chrome新标签页后,搜索框下毅然出现了视频网站的美妆节广告!

这个广告的出现位置,是非常套路的。这个位置在之前版本,也有用户觉察过有其他内容,例如疫情方面的提醒信息等,大家也没怎么将它往广告方面想。现在,这个位置就是出现了广告,虽然广告主要面向国外用户,国内用户比较少有机会看到,但还是很令人膈应的。而且,这个广告没有明确的关闭位置,这才是最大的问题。

如果你就是不想看到Chrome有乱七八糟的广告出现的可能,要怎么办?我们可以通过隐藏设置,来关闭这个广告位。

在Chrome的地址栏输入以下字符:

按下回车键,进入Chrome的实验性功能设置。

在其中,找到Enable promos for sync trusted vault passphrase”的设置项,将其改为disable关闭。

之后重启Chrome浏览器,新标签页的地址栏下面就不会出现推广内容了。

总的来说,关闭Chrome的这个推广内容位置还是比较简单的,如果你遇到了类似问题,不妨尝试一下本文的方法吧。

未经允许不得转载: CIFCOM跨境电商 » 闲鱼app广告

相关文章

themebetter

contact