Skip to content

Commit dd22720

Browse files
committed
Fix selection
1 parent 397ff76 commit dd22720

12 files changed

+12
-12
lines changed

javascripts/Go to CVE.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text.');
1010
} else {
1111
selection = selection.trim();

javascripts/Google Translate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
location.href = 'https://translate.google.com/?op=websites&langpair=auto%7Cauto&u=' + encodeURIComponent(location.href);
1010
} else {
1111
location.href = 'https://translate.google.com/?op=translate&langpair=auto%7Cauto&ie=' + encodeURIComponent(document.characterSet) + '&text=' + encodeURIComponent(selection);

javascripts/NATO spell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (window.getSelection) {
4343
} else if (document.selection && document.selection.type !== "Control") {
4444
selection = document.selection.createRange().text;
4545
}
46-
if (selection === undefined) {
46+
if (selection === undefined || selection.length === 0) {
4747
window.alert('Select the desired text.');
4848
} else {
4949
selection = selection.trim();

javascripts/Search Amazon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://www.amazon.com/s?k=' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search Bing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://www.bing.com/search?q=' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search DuckDuckGo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://duckduckgo.com/?q=' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search Google Maps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://www.google.com/maps/search/' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search Google Web.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://www.google.com/search?udm=14&q=' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search Reddit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://www.reddit.com/search?q=' + encodeURIComponent(selection.trim()), '_blank').focus();

javascripts/Search StackOverflow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (window.getSelection) {
55
} else if (document.selection && document.selection.type !== "Control") {
66
selection = document.selection.createRange().text;
77
}
8-
if (selection === undefined) {
8+
if (selection === undefined || selection.length === 0) {
99
window.alert('Select the desired text to search.');
1010
} else {
1111
window.open('https://stackoverflow.com/search?q=' + encodeURIComponent(selection.trim()), '_blank').focus();

0 commit comments

Comments
 (0)