Use js code to dynamically control the link label of the web page

explore the background

I don’t know if you have ever used a sub-site similar to a franchise agency. You can only add simple js codes or edit friendship links, or you can only fill in a record number. You have no authority to control the main source code of the website. But you want to change some styles or links!
For example, you want to set a favicon.ico for your website

js implements dynamic modification of favicon.ico

<script type="text/javascript">
var link = document.createElement("link");//先获取link标签对象
link.rel = "shortcut icon";//设置rel类型
link.href = "此处填写你的图标文件绝对地址";//设置href链接
document.head.appendChild(link);//输出修改
</script>

Haha, it can be regarded as a curve to save the country! Using this method can draw inferences from one instance to achieve many functions,
such as:

<script type="text/javascript">
$("#sub_01").append('<li><a href="/1/">备案域名</a></li>');
//$(".new-user").detach();
$("#mainlevel_10").detach();
$('#sub_07 li:contains(店铺排行榜 )').detach();
//$('.hearnav a:contains(域名竞价)').attr("href","?system_hc_xxx=y");
//$('.hearnav a:contains(域名竞价)').text('更新缓存');
$("#nav").append('<li class="mainlevel " id="mainlevel_018"><a style="color:yellow;" href="#">便捷购买</a><ul id="sub_018" ><li><a href="/?/yba.htm">5元域名</a></li></ul></li>');
$("#nav").append('<li class="mainlevel " id="mainlevel_018"><a style="color:yellow;" href="#">功能导航</a><ul id="sub_018" ><li><a href="/user_shop_add.htm" target="_blank">域名提交出售</a></li><li><a href="/user_jiexi.htm" target="_blank">域名批量解析</a></li><li><a href="http://www.chaicp.com/home_cha/chadns" target="_blank">DNS批量查询</a></li><li><a href="/user_shop_dianpu.htm">域名交易开店</a></li><li><a href="//masuyun.com" target="_blank"><font color="#0000ff">云服务器购买</font></a></li></ul></li>');
$('body').append('<div id="jm-bottombar" style="text-align: center;"><div class="navbar-box">Yumingku.Net 域名交易平台,业务范围涵盖域名注册,域名交易、过期域名抢注,域名买卖等服务,同时为用户提供全面的域名查询服务,域名库带您进入一个不一样的域名世界。</div></div>');

var link = document.createElement("link");
link.rel = "shortcut icon";
link.href = "";
document.head.appendChild(link);

console.log(window.location.pathname);
var url = window.location.href;
if(url.indexOf("/ykj") >= 0 ) {
    
    
$('.orders .paicontent ul').detach();//删除原内容
//替换新内容
$(".orders .paicontent").append('<ul><li><strong>一口价推荐:</strong></li><li><a href="/mai-yes.htm?23594476" target="_blank" class="paidomain">81ym.cn</a><br></li><li><a href="https://www.bojinmi.com" target="_blank" class="paidomain">bojinmi.com</a><br></li><li><a href="/mai-yes.htm?23995035" target="_blank" class="paidomain">Lwvip.com</a><br></li><li><a href="/mai-yes.htm?23995032" target="_blank" class="paidomain">szmqhx.Com</a><br></li><li><a href="/mai-yes.htm?ym=quduomi.com" target="_blank" class="paidomain">quduomi.com</a><br></li><li style="margin-right:0;"><a href="/mai-yes.htm?24035929" target="_blank" class="paidomain">siyinet.Com</a><br></li></ul>');
}
</script>

The above code is only for study and research, only to show the use of the detach and append functions of js!

Guess you like

Origin blog.csdn.net/Sncdma/article/details/106268452