UC浏览器真烦人,在页面强制插入JS,强制给关键词加入神马搜索链接,通过以下代码可以轻松清除,基于jQuery:
function ClearUcInlink(){ $("a").each(function(index, element) { try{ var thishref=$(this).attr("href"); var thisText=$(this).html(); if(thishref.indexOf("uc.cn")>=0){ $(this).replaceWith(thisText); } } catch(e){ } }); $("script").each(function(index, element) { try{ var thissrc=$(this).attr("src"); if(thissrc.indexOf("ucbrowser")>=0){ $(this).remove(); } } catch(e){ } }); } $(function(){ var pageDATA_ua = window.navigator.userAgent.toLowerCase(); if(pageDATA_ua.indexOf('ucbrowser')>=0){setInterval("ClearUcInlink();",1000);} }); //屏蔽UC 猜你喜欢代码 document.writeln("<style type=\"text\/css\">"); document.writeln("iframe[id^='head__'] { display: none !important;}"); document.writeln("iframe[src*='ucweb.com'] { display: none !important; }"); document.writeln("<\/style>"); //clear Ucbrowser Inlink End
屏蔽UC猜你喜欢的代码可以任选一下几种:
<style type="text/css"> /* 方法一、确定你的页面上所有正常样式都不是以 下划线 _ 开头的则可以这样处理 */ div[id^="_"] { display: none !important; } /* 方法二、原理同样,稍微安全点的写法,我们隐藏掉他的两个iframe就好,他的 id 容易区分 */ iframe[id^="head__"] { display: none !important; } iframe[id^="utp__"] { display: none !important; } /* 方法三、也是用到 CSS 的正则选择器,我们直接屏蔽掉和 UC 相关的所有框架 */ iframe[src*="ucweb.com"] { display: none !important; } /* 以上三种方法任选其一即可,但最终效果还是有些细微不同的,根据你网站的实际效果来选择吧,二三两种方法会有些UC残余垃圾代码会留在页面上,只是不明显,第一种就是容易误杀 */ </style>
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
相关文章