Skip to content

Commit

Permalink
fix event prevention issue
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Dec 13, 2017
1 parent eb61bd5 commit 6541e8a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Polyglot.safariextension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>2.2.0</string>
<string>2.3.0</string>
<key>CFBundleVersion</key>
<string>2.2.0</string>
<string>2.3.0</string>
<key>Chrome</key>
<dict>
<key>Context Menu Items</key>
Expand Down
16 changes: 16 additions & 0 deletions Polyglot.safariextension/Settings.plist
Original file line number Diff line number Diff line change
Expand Up @@ -209,40 +209,56 @@
<dict>
<key>DefaultValue</key>
<string>false</string>
<key>FalseValue</key>
<string>false</string>
<key>Key</key>
<string>useMetaKey</string>
<key>Title</key>
<string>Command</string>
<key>TrueValue</key>
<string>true</string>
<key>Type</key>
<string>CheckBox</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>false</string>
<key>FalseValue</key>
<string>false</string>
<key>Key</key>
<string>useShiftKey</string>
<key>Title</key>
<string>Shift</string>
<key>TrueValue</key>
<string>true</string>
<key>Type</key>
<string>CheckBox</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>true</string>
<key>FalseValue</key>
<string>false</string>
<key>Key</key>
<string>useCtrlKey</string>
<key>Title</key>
<string>Ctrl</string>
<key>TrueValue</key>
<string>true</string>
<key>Type</key>
<string>CheckBox</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>false</string>
<key>FalseValue</key>
<string>false</string>
<key>Key</key>
<string>useAltKey</string>
<key>Title</key>
<string>Alt</string>
<key>TrueValue</key>
<string>true</string>
<key>Type</key>
<string>CheckBox</string>
</dict>
Expand Down
21 changes: 10 additions & 11 deletions Polyglot.safariextension/injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ function handleMouseUp(e) {

function handleKeypress(e) {
// Check if shortcut key is properly configured
if (settings.keyValue === '') {
return;
}
if (settings.keyValue !== '') {
const applyMeta = settings.useMetaKey === 'true' ? e.metaKey : true;
const applyShift = settings.useShiftKey === 'true' ? e.shiftKey : true;
const applyCtrl = settings.useCtrlKey === 'true' ? e.ctrlKey : true;
const applyAlt = settings.useAltKey === 'true' ? e.altKey : true;
const applyKey = settings.keyValue.charCodeAt(0) === e.keyCode;

const applyMeta = settings.useMetaKey === 'true' ? e.metaKey : true;
const applyShift = settings.useShiftKey === 'true' ? e.shiftKey : true;
const applyCtrl = settings.useCtrlKey === 'true' ? e.ctrlKey : true;
const applyAlt = settings.useAltKey === 'true' ? e.altKey : true;
const applyKey = settings.keyValue.charCodeAt(0) === e.keyCode;
if (applyMeta && applyShift && applyCtrl && applyAlt && applyKey) {
e.preventDefault();
getSelectedText();
if (applyMeta && applyShift && applyCtrl && applyAlt && applyKey) {
e.preventDefault();
getSelectedText();
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions docs/manifest.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<key>Developer Identifier</key>
<string>58XDWHK3JX</string>
<key>CFBundleVersion</key>
<string>2.2.0</string>
<string>2.3.0</string>
<key>CFBundleShortVersionString</key>
<string>2.2.0</string>
<string>2.3.0</string>
<key>URL</key>
<string>https://github.com/uetchy/Polyglot/releases/download/v2.2.0/Polyglot.safariextz</string>
<string>https://github.com/uetchy/Polyglot/releases/download/v2.3.0/Polyglot.safariextz</string>
<key>Update From Gallery</key>
<false/>
</dict>
Expand Down

0 comments on commit 6541e8a

Please sign in to comment.