我尝试在Yourls官方书签中进行修改,但不起作用,我确定这是愚蠢的事情,但我的知识有限。
代码是:
javascript:(function(){ var d=document, sc=d.createElement('script'), l=d.location.href, enc=encodeURIComponent, ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0], ur=l.split(new RegExp(ups))[1], ups=ups.split(/\:/), p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); window.yourls_callback=function(r){ if(r.short_url){ prompt(r.message,r.short_url);}else{ alert('An error occured: '+r.message);}}; sc.src='https://xxxxxxxxx.com/xxx/admin/index.php'+p+'&jsonp=yourls'; void(d.body.appendChild(sc));})();
我想通过添加以前的代码来修改从浏览器获取的url,如下所示:
javascript:(function(){ var d=document, sc=d.createElement('script'), l='https://xxxxxxxxxxxx'+d.location.href, enc=encodeURIComponent, ups=l.match(/^[a-zA-Z0-9\+\.-]+:(\/\/)?/)[0], ur=l.split(new RegExp(ups))[1], ups=ups.split(/\:/), p='?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); window.yourls_callback=function(r){ if(r.short_url){ prompt(r.message,r.short_url);}else{ alert('An error occured: '+r.message);}}; sc.src='https://xxxxxxxxx.com/xxx/admin/index.php'+p+'&jsonp=yourls'; void(d.body.appendChild(sc));})();
已替换 l = d.location.href 至 l ='https://xxxxxxxxxxxx'+ d.location.href
但是到达YOURLS的网址仅为https://xxxxxxxxxxxx,没有添加+ d.location.href。
感谢您的任何帮助。