aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay A <vraravam@users.noreply.github.com>2022-04-20 00:51:03 -0500
committerLibravatar Vijay A <vraravam@users.noreply.github.com>2022-04-20 00:51:03 -0500
commit8477741d82e4ebac9ffb7ff90dde1dec063eaed0 (patch)
tree6c7f729b93b4f0a54f36df3815283f34a7143db7
parentIgnore the 'all.json' file since that is going to be autogenerated anyways (diff)
downloadferdium-recipes-8477741d82e4ebac9ffb7ff90dde1dec063eaed0.tar.gz
ferdium-recipes-8477741d82e4ebac9ffb7ff90dde1dec063eaed0.tar.zst
ferdium-recipes-8477741d82e4ebac9ffb7ff90dde1dec063eaed0.zip
Remove duplicate code and reuse 'Ferdium.openNewWindow()'
-rw-r--r--recipes/discord/package.json2
-rw-r--r--recipes/discord/webview.js46
-rw-r--r--recipes/skype/package.json2
-rw-r--r--recipes/skype/webview.js20
-rw-r--r--recipes/steamchat/package.json2
-rw-r--r--recipes/steamchat/webview.js20
-rw-r--r--recipes/zoom/package.json2
-rw-r--r--recipes/zoom/webview.js46
8 files changed, 38 insertions, 102 deletions
diff --git a/recipes/discord/package.json b/recipes/discord/package.json
index 1dc89b4..0fa9651 100644
--- a/recipes/discord/package.json
+++ b/recipes/discord/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "discord", 2 "id": "discord",
3 "name": "Discord", 3 "name": "Discord",
4 "version": "1.7.0", 4 "version": "1.7.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://discordapp.com/login", 7 "serviceURL": "https://discordapp.com/login",
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js
index 16a3a1a..0dd0e38 100644
--- a/recipes/discord/webview.js
+++ b/recipes/discord/webview.js
@@ -4,7 +4,7 @@ function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj }; 4 return obj && obj.__esModule ? obj : { default: obj };
5} 5}
6 6
7module.exports = (Ferdium, settings) => { 7module.exports = Ferdium => {
8 const getMessages = () => { 8 const getMessages = () => {
9 let directCount = 0; 9 let directCount = 0;
10 const directCountPerServer = document.querySelectorAll( 10 const directCountPerServer = document.querySelectorAll(
@@ -26,40 +26,18 @@ module.exports = (Ferdium, settings) => {
26 26
27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
28 28
29 // TODO: This whole block is duplicated between the 'discord' and 'skype' recipes - reuse 29 document.addEventListener('click', event => {
30 document.addEventListener( 30 const link = event.target.closest('a[href^="http"]');
31 'click', 31 const button = event.target.closest('button[title^="http"]');
32 event => {
33 const link = event.target.closest('a[href^="http"]');
34 const button = event.target.closest('button[title^="http"]');
35 32
36 if (link || button) { 33 if (link || button) {
37 const url = link 34 const url = link ? link.getAttribute('href') : button.getAttribute('title');
38 ? link.getAttribute('href')
39 : button.getAttribute('title');
40 35
41 if (url.includes('views/imgpsh_fullsize_anim')) { 36 if (url.includes('views/imgpsh_fullsize_anim')) {
42 event.preventDefault(); 37 event.preventDefault();
43 event.stopPropagation(); 38 event.stopPropagation();
44 // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) 39 Ferdium.openNewWindow(url);
45 // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/ferdium/ferdium-app/issues/1697)
46 let win = new Ferdium.BrowserWindow({
47 width: 800,
48 height: window.innerHeight,
49 minWidth: 600,
50 webPreferences: {
51 partition: `persist:service-${settings.id}`,
52 // TODO: Aren't these needed here?
53 // contextIsolation: false,
54 },
55 });
56 win.loadURL(url);
57 win.on('closed', () => {
58 win = null;
59 });
60 }
61 } 40 }
62 }, 41 }
63 true, 42 }, true);
64 );
65}; 43};
diff --git a/recipes/skype/package.json b/recipes/skype/package.json
index a3a0840..afebf64 100644
--- a/recipes/skype/package.json
+++ b/recipes/skype/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "skype", 2 "id": "skype",
3 "name": "Skype", 3 "name": "Skype",
4 "version": "3.5.0", 4 "version": "3.5.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.skype.com/", 7 "serviceURL": "https://web.skype.com/",
diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js
index ca0befb..47b6f27 100644
--- a/recipes/skype/webview.js
+++ b/recipes/skype/webview.js
@@ -2,7 +2,7 @@ const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4 4
5module.exports = (Ferdium, settings) => { 5module.exports = Ferdium => {
6 const getMessages = () => { 6 const getMessages = () => {
7 let count = 0; 7 let count = 0;
8 const container = document.querySelector('[role="tablist"] > button > div'); 8 const container = document.querySelector('[role="tablist"] > button > div');
@@ -30,7 +30,6 @@ module.exports = (Ferdium, settings) => {
30 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 30 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
31 Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); 31 Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js'));
32 32
33 // TODO: This whole block is duplicated between the 'discord' and 'skype' recipes - reuse
34 document.addEventListener('click', event => { 33 document.addEventListener('click', event => {
35 const link = event.target.closest('a[href^="http"]'); 34 const link = event.target.closest('a[href^="http"]');
36 const button = event.target.closest('button[title^="http"]'); 35 const button = event.target.closest('button[title^="http"]');
@@ -41,22 +40,7 @@ module.exports = (Ferdium, settings) => {
41 if (url.includes('views/imgpsh_fullsize_anim')) { 40 if (url.includes('views/imgpsh_fullsize_anim')) {
42 event.preventDefault(); 41 event.preventDefault();
43 event.stopPropagation(); 42 event.stopPropagation();
44 // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) 43 Ferdium.openNewWindow(url);
45 // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/ferdium/ferdium-app/issues/1697)
46 let win = new Ferdium.BrowserWindow({
47 width: 800,
48 height: window.innerHeight,
49 minWidth: 600,
50 webPreferences: {
51 partition: `persist:service-${settings.id}`,
52 // TODO: Aren't these needed here?
53 // contextIsolation: false,
54 }
55 });
56 win.loadURL(url);
57 win.on('closed', () => {
58 win = null;
59 });
60 } 44 }
61 } 45 }
62 }, true); 46 }, true);
diff --git a/recipes/steamchat/package.json b/recipes/steamchat/package.json
index ffc6230..28434b1 100644
--- a/recipes/steamchat/package.json
+++ b/recipes/steamchat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "steamchat", 2 "id": "steamchat",
3 "name": "SteamChat", 3 "name": "SteamChat",
4 "version": "1.4.0", 4 "version": "1.4.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://steamcommunity.com/chat", 7 "serviceURL": "https://steamcommunity.com/chat",
diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js
index cfe84f3..1188c71 100644
--- a/recipes/steamchat/webview.js
+++ b/recipes/steamchat/webview.js
@@ -30,17 +30,13 @@ module.exports = Ferdium => {
30 30
31 Ferdium.loop(getMessages); 31 Ferdium.loop(getMessages);
32 32
33 document.addEventListener( 33 document.addEventListener('click', event => {
34 'click', 34 const link = event.target.closest('a[href^="http"]');
35 event => {
36 const link = event.target.closest('a[href^="http"]');
37 35
38 if (link && link.getAttribute('target') === '_top') { 36 if (link && link.getAttribute('target') === '_top') {
39 event.preventDefault(); 37 event.preventDefault();
40 event.stopPropagation(); 38 event.stopPropagation();
41 Ferdium.openNewWindow(link.getAttribute('href')); 39 Ferdium.openNewWindow(link.getAttribute('href'));
42 } 40 }
43 }, 41 }, true);
44 true,
45 );
46}; 42};
diff --git a/recipes/zoom/package.json b/recipes/zoom/package.json
index ce12ff9..82117f7 100644
--- a/recipes/zoom/package.json
+++ b/recipes/zoom/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "zoom", 2 "id": "zoom",
3 "name": "Zoom", 3 "name": "Zoom",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://zoom.us/join", 7 "serviceURL": "https://zoom.us/join",
diff --git a/recipes/zoom/webview.js b/recipes/zoom/webview.js
index 16a3a1a..0dd0e38 100644
--- a/recipes/zoom/webview.js
+++ b/recipes/zoom/webview.js
@@ -4,7 +4,7 @@ function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj }; 4 return obj && obj.__esModule ? obj : { default: obj };
5} 5}
6 6
7module.exports = (Ferdium, settings) => { 7module.exports = Ferdium => {
8 const getMessages = () => { 8 const getMessages = () => {
9 let directCount = 0; 9 let directCount = 0;
10 const directCountPerServer = document.querySelectorAll( 10 const directCountPerServer = document.querySelectorAll(
@@ -26,40 +26,18 @@ module.exports = (Ferdium, settings) => {
26 26
27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
28 28
29 // TODO: This whole block is duplicated between the 'discord' and 'skype' recipes - reuse 29 document.addEventListener('click', event => {
30 document.addEventListener( 30 const link = event.target.closest('a[href^="http"]');
31 'click', 31 const button = event.target.closest('button[title^="http"]');
32 event => {
33 const link = event.target.closest('a[href^="http"]');
34 const button = event.target.closest('button[title^="http"]');
35 32
36 if (link || button) { 33 if (link || button) {
37 const url = link 34 const url = link ? link.getAttribute('href') : button.getAttribute('title');
38 ? link.getAttribute('href')
39 : button.getAttribute('title');
40 35
41 if (url.includes('views/imgpsh_fullsize_anim')) { 36 if (url.includes('views/imgpsh_fullsize_anim')) {
42 event.preventDefault(); 37 event.preventDefault();
43 event.stopPropagation(); 38 event.stopPropagation();
44 // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) 39 Ferdium.openNewWindow(url);
45 // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/ferdium/ferdium-app/issues/1697)
46 let win = new Ferdium.BrowserWindow({
47 width: 800,
48 height: window.innerHeight,
49 minWidth: 600,
50 webPreferences: {
51 partition: `persist:service-${settings.id}`,
52 // TODO: Aren't these needed here?
53 // contextIsolation: false,
54 },
55 });
56 win.loadURL(url);
57 win.on('closed', () => {
58 win = null;
59 });
60 }
61 } 40 }
62 }, 41 }
63 true, 42 }, true);
64 );
65}; 43};