parent
939718f0c2
commit
62f038cb4b
|
|
@ -12,8 +12,10 @@ chrome.contextMenus.onClicked.addListener((info) => {
|
||||||
if (selectedText.startsWith('#')) {
|
if (selectedText.startsWith('#')) {
|
||||||
selectedText = selectedText.substring(1);
|
selectedText = selectedText.substring(1);
|
||||||
}
|
}
|
||||||
const fixedUrl = 'https://ot.syncore.at/view.php?id=';
|
chrome.storage.sync.get(['customUrl'], (result) => {
|
||||||
const completeUrl = `${fixedUrl}${selectedText}`;
|
const fixedUrl = result.customUrl || 'https://example.com/view.php?id=';
|
||||||
chrome.tabs.create({ url: completeUrl });
|
const completeUrl = `${fixedUrl}${selectedText}`;
|
||||||
|
chrome.tabs.create({ url: completeUrl });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Open in Mantis",
|
"name": "Open in Mantis",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"permissions": ["contextMenus"],
|
"permissions": ["contextMenus", "storage"],
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "background.js"
|
"service_worker": "background.js"
|
||||||
},
|
},
|
||||||
"description": "Open selected number in Mantis"
|
"description": "Open selected number in Mantis",
|
||||||
|
"options_page": "options.html"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Options</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="optionsForm">
|
||||||
|
<label for="customUrl">Custom URL:</label>
|
||||||
|
<input type="text" id="customUrl">
|
||||||
|
<button type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
<script src="options.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
chrome.storage.sync.get(['customUrl'], (result) => {
|
||||||
|
document.getElementById('customUrl').value = result.customUrl || 'https://example.com/view.php?id=';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('optionsForm').addEventListener('submit', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const customUrl = document.getElementById('customUrl').value;
|
||||||
|
chrome.storage.sync.set({ customUrl }, () => {
|
||||||
|
alert('Options saved.');
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue