This commit is contained in:
Tijl 2022-12-25 17:58:17 +01:00
parent b4e68779e1
commit ea4b512429
5 changed files with 14 additions and 11 deletions

View File

@ -1,7 +1,8 @@
var config = { var config = {
shlinkUrl: 'https://example.com', // Base url of your shlink server customName: 'Redirect Extention',// Custom name for the extention
shlinkOutUrl: 'https://example.com', // The most cases this is the same as shlinkUrl shlinkUrl: 'https://example.com',// Base url of your shlink server
shlinkAppUrl: 'https://app.shlink.io/server/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // Base url for shlink app. See example. Selfhosted or app.shlink.io shlinkOutUrl: 'https://example.com',// The most cases this is the same as shlinkUrl
shlinkApiKey: 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // Shlink API Key shlinkAppUrl: 'https://app.shlink.io/server/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',// Base url for shlink app. See example. Selfhosted or app.shlink.io
shlinkAppOpenMode: 'edit' // Changes the use of the Open App button to the shortUrl settings (edit) or visits info. Choose 'visits' or 'edit'. shlinkApiKey: 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',// Shlink API Key
shlinkAppOpenMode: 'edit'// Changes the use of the Open App button to the shortUrl settings (edit) or visits info. Choose 'visits' or 'edit'.
} }

View File

@ -17,6 +17,8 @@ function newRedirect () {
var responseData = JSON.parse(request.response); var responseData = JSON.parse(request.response);
shortUrlOut.value = `${config.shlinkOutUrl}/${responseData.shortCode}`; shortUrlOut.value = `${config.shlinkOutUrl}/${responseData.shortCode}`;
shlinkAppBtnRdUrl = `${config.shlinkAppUrl}/short-code/${responseData.shortCode}/${config.shlinkAppOpenMode}`; shlinkAppBtnRdUrl = `${config.shlinkAppUrl}/short-code/${responseData.shortCode}/${config.shlinkAppOpenMode}`;
document.getElementById("newButton").style.display = 'none';
document.getElementById("cancelButton").style.display = 'block';
document.getElementById("p1qr-code").src = `${config.shlinkUrl}/${responseData.shortCode}/qr-code?size=160&format=png&margin=2&errorCorrection=L`; document.getElementById("p1qr-code").src = `${config.shlinkUrl}/${responseData.shortCode}/qr-code?size=160&format=png&margin=2&errorCorrection=L`;
} }
}); });

View File

@ -4,5 +4,5 @@
.title { .title {
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
padding: 12px; padding: 8px 24px 2px;
} }

View File

@ -2,11 +2,9 @@
<script src="popup-func.js"></script> <script src="popup-func.js"></script>
<div class="container"> <div class="container">
<div> <div>
<div class="title">Redirect Extention</div> <p class="title" id="title">...</p>
<button id="newButton">New</button> <br><button id="newButton">New</button><button id="cancelButton" style="display: none;">Cancel</button> <input id="output-shortUrl" type="text" disabled> <button id="copyShortUrl-btn">Copy ShortUrl</button> <button id="openShlinkApp-btn">Open App</button><br>
<input id="output-shortUrl" type="text" disabled> <br><img id="p1qr-code" src="">
<button id="copyShortUrl-btn">Copy ShortUrl</button> <button id="openShlinkApp-btn">Open App</button>
<img id="p1qr-code" src="">
</div> </div>
</div> </div>
<script src="config.js"></script> <script src="config.js"></script>

View File

@ -2,6 +2,8 @@ const searchButton = document.getElementById('searchButton');
var shlinkAppBtnRdUrl = `${config.shlinkAppUrl}`; var shlinkAppBtnRdUrl = `${config.shlinkAppUrl}`;
document.getElementById('title').innerHTML = config.customName
if (searchButton) { if (searchButton) {
searchButton.addEventListener('click', () => { searchButton.addEventListener('click', () => {
searchRedirect(); searchRedirect();