diff --git a/cfg/conf.sample.php b/cfg/conf.sample.php
index ed494b7..f664198 100644
--- a/cfg/conf.sample.php
+++ b/cfg/conf.sample.php
@@ -56,6 +56,12 @@ languageselection = false
; the pastes encryption key
; urlshortener = "https://shortener.example.com/api?link="
+; you can set urlshortenerajax to true if the shortener returns the url plain text
+; YOU HAVE TO set Control-Allow-Origin header in the link shortener Server!
+; https://enable-cors.org/server_apache.html
+; https://enable-cors.org/server_nginx.html
+; urlshortenerajax = "false"
+
; (optional) Let users create a QR code for sharing the paste URL with one click.
; It works both when a new paste is created and when you view a paste.
; qrcode = true
diff --git a/js/privatebin.js b/js/privatebin.js
index 48dc7a0..7ac8ea6 100644
--- a/js/privatebin.js
+++ b/js/privatebin.js
@@ -1195,8 +1195,21 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
*/
function sendToShortener()
{
- window.location.href = $shortenButton.data('shortener') +
- encodeURIComponent($pasteUrl.attr('href'));
+ var url = $shortenButton.data('shortener') + encodeURIComponent($pasteUrl.attr('href'));
+
+ if($shortenButton.data('ajax'))
+ {
+ $.get(url, function(d) {
+ $pasteUrl.attr(d);
+ $pasteUrl.text(d);
+ Helper.selectText($pasteUrl[0]);
+ $shortenButton.remove();
+ })
+ }
+ else
+ {
+ window.location.href = url;
+ }
}
/**
diff --git a/lib/Configuration.php b/lib/Configuration.php
index f505b90..5b2b58f 100644
--- a/lib/Configuration.php
+++ b/lib/Configuration.php
@@ -52,6 +52,7 @@ class Configuration
'languageselection' => false,
'languagedefault' => '',
'urlshortener' => '',
+ 'urlshortenerajax' => '',
'qrcode' => true,
'icon' => 'identicon',
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; media-src data:; object-src data:; Referrer-Policy: \'no-referrer\'; sandbox allow-same-origin allow-scripts allow-forms allow-popups',
diff --git a/lib/PrivateBin.php b/lib/PrivateBin.php
index 39fb2db..72bd742 100644
--- a/lib/PrivateBin.php
+++ b/lib/PrivateBin.php
@@ -447,6 +447,7 @@ class PrivateBin
$page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
$page->assign('EXPIRECLONE', !$this->_doesExpire || ($this->_doesExpire && $this->_conf->getKey('clone', 'expire')));
$page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener'));
+ $page->assign('URLSHORTENERAJAX', $this->_conf->getKey('urlshortenerajax'));
$page->assign('QRCODE', $this->_conf->getKey('qrcode'));
$page->draw($this->_conf->getKey('template'));
}
diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php
index ab95dfc..e674aa0 100644
--- a/tpl/bootstrap.php
+++ b/tpl/bootstrap.php
@@ -75,7 +75,7 @@ if ($MARKDOWN):
-
+
@@ -473,7 +473,7 @@ endif;
-