Path for configureCommands is chosen based on user's browser (Opera incomatibility)
This commit is contained in:
parent
1d30b19132
commit
0e6c5e35ac
13
messaging.js
13
messaging.js
|
@ -131,3 +131,16 @@ function stringAsRegExp(s, flags) {
|
||||||
function wildcardAsRegExp(s, flags) {
|
function wildcardAsRegExp(s, flags) {
|
||||||
return new RegExp(s.replace(/[{}()\[\]\/\\.+?^$:=!|]/g, "\\$&").replace(/\*/g, '.*?'), flags);
|
return new RegExp(s.replace(/[{}()\[\]\/\\.+?^$:=!|]/g, "\\$&").replace(/\*/g, '.*?'), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var configureCommands = {
|
||||||
|
get url () {
|
||||||
|
return navigator.userAgent.indexOf('OPR') > -1 ?
|
||||||
|
'opera://settings/configureCommands' :
|
||||||
|
'chrome://extensions/configureCommands'
|
||||||
|
},
|
||||||
|
open: () => {
|
||||||
|
chrome.tabs.create({
|
||||||
|
'url': configureCommands.url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
/* globals configureCommands */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
document.querySelector('#manage-options-button').addEventListener("click", function() {
|
document.querySelector('#manage-options-button').addEventListener("click", function() {
|
||||||
if (chrome.runtime.openOptionsPage) {
|
if (chrome.runtime.openOptionsPage) {
|
||||||
// Supported (Chrome 42+)
|
// Supported (Chrome 42+)
|
||||||
|
@ -8,11 +11,7 @@ document.querySelector('#manage-options-button').addEventListener("click", funct
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('#manage-shortcuts-button').addEventListener("click", function() {
|
document.querySelector('#manage-shortcuts-button').addEventListener("click", configureCommands.open);
|
||||||
chrome.tabs.create({
|
|
||||||
'url': 'chrome://extensions/configureCommands'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelector('#editor-styles-button').addEventListener("click", function() {
|
document.querySelector('#editor-styles-button').addEventListener("click", function() {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
2: <span i18n-text="optionsOpenManagerNote"></span>, <a href="#" data-cmd="open-keyboard">chrome://extensions/configureCommands</a>
|
2: <span i18n-text="optionsOpenManagerNote"></span>, <a href="#" data-cmd="open-keyboard">chrome://extensions/configureCommands</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="/messaging.js"></script>
|
||||||
<script src="index.js"></script>
|
<script src="index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* globals configureCommands */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function restore () {
|
function restore () {
|
||||||
|
@ -88,8 +89,9 @@ document.addEventListener('click', e => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (cmd === 'open-keyboard') {
|
else if (cmd === 'open-keyboard') {
|
||||||
chrome.tabs.create({
|
configureCommands.open();
|
||||||
url: 'chrome://extensions/configureCommands'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// overwrite the default URL if browser is Opera
|
||||||
|
document.querySelector('[data-cmd="open-keyboard"]').textContent =
|
||||||
|
configureCommands.url;
|
||||||
|
|
8
popup.js
8
popup.js
|
@ -1,3 +1,5 @@
|
||||||
|
/* globals configureCommands */
|
||||||
|
|
||||||
var writeStyleTemplate = document.createElement("a");
|
var writeStyleTemplate = document.createElement("a");
|
||||||
writeStyleTemplate.className = "write-style-link";
|
writeStyleTemplate.className = "write-style-link";
|
||||||
|
|
||||||
|
@ -238,11 +240,7 @@ document.querySelector('#popup-options-button').addEventListener("click", functi
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('#popup-shortcuts-button').addEventListener("click", function() {
|
document.querySelector('#popup-shortcuts-button').addEventListener("click", configureCommands.open);
|
||||||
chrome.tabs.create({
|
|
||||||
'url': 'chrome://extensions/configureCommands'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// popup width
|
// popup width
|
||||||
document.body.style.width = (localStorage.getItem('popupWidth') || '246') + 'px';
|
document.body.style.width = (localStorage.getItem('popupWidth') || '246') + 'px';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user