ETH官方钱包

前往
大廳
主題

小書籤工具Bookmarklet:去除網址多餘參數

—— | 2024-01-30 11:21:37 | 巴幣 0 | 人氣 162

有的網站會加入一些參數,這個可以去掉,複製網址時可以乾淨簡潔
javascript:(function(){const rules={'www.bilibili.com':{testReg:/^http(?:s)?:\/\/www\.bilibili\.com\/video\/(av\d+).*$/i,replace:'https://www.bilibili.com/$1',query:['p'],hash:!0},'itunes.apple.com':{testReg:/^http(?:s)?:\/\/itunes\.apple\.com\/(?:\w{2}\/)?([^\/]+)\/(?:[^\/]+\/)?((?:id)\d+).*$/i,replace:'https://itunes.apple.com/cn/$1/$2'},'chrome.google.com/webstore':{testReg:/^http(?:s)?:\/\/chrome\.google\.com\/webstore\/detail\/[^\/]+\/([a-z]{32}).*/i,replace:'https://chrome.google.com/webstore/detail/$1'},'s.taobao.com':{testReg:/^http(?:s)?:\/\/s\.taobao\.com\/search.*$/i,replace:'https://s.taobao.com/search',query:['q']},'list.tmall.com':{testReg:/^http(?:s)?:\/\/list\.tmall\.com\/search_product\.htm.*$/i,replace:'https://list.tmall.com/search_product.htm',query:['q']},'item.taobao.com':{testReg:/^http(?:s)?:\/\/item\.taobao\.com\/item\.htm.*$/i,replace:'https://item.taobao.com/item.htm',query:['id']},'detail.tmall.com':{testReg:/^http(?:s)?:\/\/detail\.tmall\.com\/item\.htm.*$/i,replace:'https://detail.tmall.com/item.htm',query:['id']},'taobao/tmall.com/shop':{testReg:/^http(?:s)?:\/\/(\w+)\.(taobao|tmall)\.com\/shop\/view_shop\.htm.*$/i,replace:'https://$1.$2.com/'},'c.pc.qq.com':{testReg:/^http(?:s)?:\/\/c\.pc\.qq\.com\/middle.html\?.*pfurl=([^&]*)(?:&.*$|$)/i,replace:'$1',query:[],methods:['decodeUrl']},'item.m.jd.com':{testReg:/^http(?:s)?:\/\/item\.m\.jd\.com\/product\/(\d+)\.html(\?.*)?$/i,replace:'https://item.jd.com/$1.html'},'item.m.jd.com/ware/':{testReg:/^http(?:s)?:\/\/item\.m\.jd\.com\/ware\/view\.action\?.*wareId=(\d+).*$/i,replace:'https://item.jd.com/$1.html'},'search.jd.com':{testReg:/^http(?:s)?:\/\/search\.jd\.com\/Search\?.*$/i,query:['keyword','enc']},'weibo.com/u':{testReg:/^http(?:s)?:\/\/(?:www\.)?weibo\.com\/u\/(\d+)(\?.*)?$/i,replace:'https://m.weibo.cn/$1'},'weibo.com':{testReg:/^http(?:s)?:\/\/(?:www\.)?weibo\.com\/(?:\d+)\/(\w+)(\?.*)?$/i,replace:'https://m.weibo.cn/status/$1'},'greasyfork.org':{testReg:/^http(?:s)?:\/\/(?:www\.)?greasyfork\.org\/(?:[\w-]*\/)?scripts\/(\d+)-.*$/i,replace:'https://greasyfork.org/zh-CN/scripts/$1'},'store.steampowered.com|steamcommunity.com':{testReg:/^http(?:s)?:\/\/(store\.steampowered|steamcommunity)\.com\/app\/(\d+).*$/i,replace:'https://$1.com/app/$2'},'meta.appinn.com':{testReg:/^http(?:s)?:\/\/meta\.appinn\.com\/t(?:\/[^/]*[^/0-9][^/]*)*\/(\d+)(\/.*$|$)/i,replace:'https://meta.appinn.com/t/$1'},'yangkeduo.com':{testReg:/^http(?:s)?:\/\/mobile\.yangkeduo\.com\/goods.html\?.*$/i,query:['goods_id']},other:{testReg:/^(http(?:s)?:\/\/[^?#]*)[?#].*$/i,query:['id','tid','uid','q','wd','query','keyword']}};const%20pureUrl=function(url=window.location.href){const%20hash=url.replace(/^[^#]*(#.*)?$/,'$1'),base=url.replace(/(\?|#).*$/,'');let%20pureUrl=url;const%20getQueryString=function(key){let%20ret=url.match(new%20RegExp('(?:\\?|&)('+key+'=[^?#&]*)','i'));return%20null===ret?'':ret[1]},methods={decodeUrl:function(url){return%20decodeURIComponent(url)}};for(let%20i%20in%20rules){let%20rule=rules[i],reg=rule.testReg,replace=rule.replace;if(reg.test(url)){let%20newQuerys='';void%200!==rule.query&&rule.query.length>0&&rule.query.map(query=>{const%20ret=getQueryString(query);''!==ret&&(newQuerys+=(newQuerys.length?'&':'?')+ret)}),newQuerys+=void%200!==rule.hash&&rule.hash?hash:'',pureUrl=(void%200===replace?base:url.replace(reg,replace))+newQuerys,void%200!==rule.methods&&rule.methods.length>0&&rule.methods.map(methodName=>{pureUrl=methods[methodName](pureUrl)});break}}return%20pureUrl}();let%20newnode=document.createElement('input');newnode.id='pure-url-for-copy',newnode.value=pureUrl,document.body.appendChild(newnode);let%20copyinput=document.getElementById('pure-url-for-copy');copyinput.select();try{document.execCommand('copy');window.location.href===pureUrl?window.location.reload():window.location.href=pureUrl}catch(err){null!=prompt('%E5%87%80%E5%8C%96%E5%90%8E%E7%9A%84%E7%BD%91%E5%9D%80%E6%98%AF%EF%BC%9A',pureUrl)&&(window.location.href=pureUrl)}document.body.removeChild(copyinput)})();

創(chuàng)作回應

更多創(chuàng)作