diff --git a/brave/manifest.json b/brave/manifest.json index 3e45820..ce43afc 100644 --- a/brave/manifest.json +++ b/brave/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/chrome/manifest.json b/chrome/manifest.json index d48159f..070dc8a 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/chromium/manifest.json b/chromium/manifest.json index 8058b83..7d9c58d 100644 --- a/chromium/manifest.json +++ b/chromium/manifest.json @@ -1,6 +1,5 @@ { "name": "Open in Chromium Browser", - "short_name": "ioichromium", "description": "Open current page, link, or all tabs in the Chromium browser.", "author": "Andy Portmen", "version": "0.1.3", @@ -39,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/common/data/inject.js b/common/data/inject.js index 8c663f6..e630a9b 100644 --- a/common/data/inject.js +++ b/common/data/inject.js @@ -9,10 +9,11 @@ const config = { enabled: false, hosts: [], urls: [], - reverse: false + reverse: false, + topRedict: false }; -const validate = (a, callback) => { +const validate = (a, callback, isTop = false) => { if (config.hosts.length) { const host = a.hostname; if (host) { @@ -30,7 +31,7 @@ const validate = (a, callback) => { } } // reverse mode - if (config.reverse && a.href && a.href.indexOf('#') === -1) { + if (config.reverse && a.href && (a.href.indexOf('#') === -1 || isTop)) { if (a.href.startsWith('http') || a.href.startsWith('file')) { return callback(a.href); } @@ -50,7 +51,7 @@ chrome.storage.local.get(config, prefs => { config.reverse = config.reverse || prefs.reverse; } // top level redirect - if (window.top === window) { + if (window.top === window && config.topRedict) { validate(location, url => { if (history.length) { history.back(); @@ -62,7 +63,39 @@ chrome.storage.local.get(config, prefs => { cmd: 'open-in', url }); - }); + }, true); + } + // Gmail attachments + // https://github.com/andy-portmen/open-in/issues/42 + if (window.top === window && location.hostname === 'mail.google.com') { + validate(location, () => { + const script = document.createElement('script'); + script.textContent = `{ + const script = document.currentScript; + const hps = Object.getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'src'); + Object.defineProperty(HTMLIFrameElement.prototype, 'src', { + set(v) { + if (v && v.indexOf('&view=att&') !== -1) { + script.dispatchEvent(new CustomEvent('open-request', { + detail: v + })); + } + else { + hps.set.call(this, v); + } + } + }); + }`; + script.addEventListener('open-request', e => { + e.stopPropagation(); + chrome.runtime.sendMessage({ + cmd: 'open-in', + url: e.detail + }); + }); + document.documentElement.appendChild(script); + script.remove(); + }, true); } }); }); @@ -86,7 +119,7 @@ document.addEventListener('click', e => { }; // hostname on left-click if (e.button === 0 && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) { - if (config.hosts.length || config.urls.length) { + if (config.hosts.length || config.urls.length || config.reverse) { let a = e.target.closest('a'); if (a) { if (a.href.startsWith('https://www.google') && a.href.indexOf('&url=') !== -1) { diff --git a/common/data/options/index.html b/common/data/options/index.html index 418a40b..73a46b9 100644 --- a/common/data/options/index.html +++ b/common/data/options/index.html @@ -4,9 +4,6 @@ Open In Options @@ -85,34 +87,27 @@

Open with Left-Click

- +
+ + + + +

Misc

- - - - - - - - - - - - - - - - - - - - - -
Path to the executable2:
-
- -
-
+
+ + + + + + +
+
+ Path to the executable2: +
+ +
+
This extension supports managed storage. Some of the preferences can be pre-configured by the domain administrator
@@ -130,6 +125,7 @@

Misc

  • By activating this option all the requested URLs are sent to the external executable at once. Only activate this option if the external executable is capable of handling this type of requests.
  • Not all key combinations are allowed in all operating systems.
  • When enabled, all left-click links except the ones that match with at least one condition will be sent to the external executable.
  • +
  • If checked, the extension validates top-level navigation with the list of left-click hostnames and URLs. If matched, the URL is sent to the external executable, and the navigation is blocked.
  • diff --git a/common/data/options/index.js b/common/data/options/index.js index 6bf9294..c8204e8 100644 --- a/common/data/options/index.js +++ b/common/data/options/index.js @@ -22,7 +22,8 @@ function restore() { multiple: app.multiple, hosts: [], urls: [], - reverse: false + reverse: false, + topRedict: false }, prefs => { document.getElementById('path').value = prefs.path; document.getElementById('enabled').checked = prefs.enabled; @@ -37,6 +38,7 @@ function restore() { document.getElementById('hosts').value = prefs.hosts.join(', '); document.getElementById('urls').value = prefs.urls.join(', '); document.getElementById('reverse').checked = prefs.reverse; + document.getElementById('topRedict').checked = prefs.topRedict; }); } @@ -54,6 +56,7 @@ function save() { const hosts = document.getElementById('hosts').value; const urls = document.getElementById('urls').value; const reverse = document.getElementById('reverse').checked; + const topRedict = document.getElementById('topRedict').checked; chrome.storage.local.set({ path, @@ -72,7 +75,8 @@ function save() { .filter((h, i, l) => h && l.indexOf(h) === i), urls: urls.split(/\s*,\s*/).filter(s => s.startsWith('http') || s.startsWith('file')) .filter((h, i, l) => h && l.indexOf(h) === i), - reverse + reverse, + topRedict }, () => { restore(); const status = document.getElementById('status'); diff --git a/common/data/options/matched.js b/common/data/options/matched.js index 219c8b3..543d09d 120000 --- a/common/data/options/matched.js +++ b/common/data/options/matched.js @@ -1 +1 @@ -../../../../shared/matched/matched.js \ No newline at end of file +../../../../_/matched/matched.js \ No newline at end of file diff --git a/common/data/options/matched.json b/common/data/options/matched.json index 4b96f57..003b56f 120000 --- a/common/data/options/matched.json +++ b/common/data/options/matched.json @@ -1 +1 @@ -../../../../shared/matched/matched.json \ No newline at end of file +../../../../_/matched/matched.json \ No newline at end of file diff --git a/edge/manifest.json b/edge/manifest.json index e07f13a..ee2787d 100644 --- a/edge/manifest.json +++ b/edge/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/firefox/manifest.json b/firefox/manifest.json index a3a1db4..8c5407c 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/ie/manifest.json b/ie/manifest.json index e920278..097f240 100644 --- a/ie/manifest.json +++ b/ie/manifest.json @@ -1,6 +1,5 @@ { "name": "Open in IE", - "short_name": "ioiie", "description": "Open current page, link, or all tabs in the Internet Explorer browser.", "author": "Andy Portmen", "version": "0.2.3", @@ -39,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/opera/manifest.json b/opera/manifest.json index 320a2f8..f1d7192 100644 --- a/opera/manifest.json +++ b/opera/manifest.json @@ -1,6 +1,5 @@ { "name": "Open in Opera", - "short_name": "ioiopera", "description": "Open current page, link, or all tabs in the Opera browser.", "author": "Andy Portmen", "version": "0.1.9", @@ -39,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/palemoon/manifest.json b/palemoon/manifest.json index d821e36..5f39e8f 100644 --- a/palemoon/manifest.json +++ b/palemoon/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/safari/manifest.json b/safari/manifest.json index b0f2f56..1de33fb 100644 --- a/safari/manifest.json +++ b/safari/manifest.json @@ -1,6 +1,5 @@ { "name": "Open in Safari", - "short_name": "ioisafari", "description": "Open current page, link, or all tabs in the Safari browser.", "author": "Andy Portmen", "version": "0.2.0", @@ -39,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/vivaldi/manifest.json b/vivaldi/manifest.json index eaaeb63..02a5671 100644 --- a/vivaldi/manifest.json +++ b/vivaldi/manifest.json @@ -1,6 +1,5 @@ { "name": "Open in Vivaldi", - "short_name": "ioivivaldi", "description": "Open current page, link, or all tabs in the Vivaldi browser.", "author": "Andy Portmen", "version": "0.1.9", @@ -39,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/waterfox/manifest.json b/waterfox/manifest.json index b26c5bd..d14ab5d 100644 --- a/waterfox/manifest.json +++ b/waterfox/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } } diff --git a/yandex/manifest.json b/yandex/manifest.json index 18e9ec2..9ba463f 100644 --- a/yandex/manifest.json +++ b/yandex/manifest.json @@ -38,10 +38,12 @@ "matches": [""], "js": ["data/inject.js"], "run_at": "document_start", - "all_frames": true + "all_frames": true, + "match_about_blank": true }], "options_ui": { "page": "data/options/index.html", - "chrome_style": true + "chrome_style": true, + "open_in_tab": true } }