Измените функцию добавления Bookmarklet Yourls - PullRequest
0 голосов
/ 04 ноября 2018

Я пытаюсь внести изменения в официальный букмарклет 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));})();

заменен л = d.location.href в л = 'https://xxxxxxxxxxxx'+d.location.href

Но URL, который прибывает в YOURLS, составляет всего https://xxxxxxxxxxxx, + d.location.href не добавляется.

Любая помощь будет оценена, спасибо.

...