From 53560dd3d21155285eb2f65b8e1571dbb33b94b1 Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 20 Apr 2020 09:09:20 +0000 Subject: Update Instagram recipe to use official web service (#111) * initial commit # Conflicts: # README.md * Adjust recipe to Ferdi Co-authored-by: Stefan Malzner --- README.md | 1 - all.json | 2 +- archives/instagram.tar.gz | Bin 144191 -> 144370 bytes icon.png | Bin 0 -> 9879 bytes icon.svg | 29 +++++++++++++++++++++++++++++ uncompressed/instagram/README.md | 6 ++++-- uncompressed/instagram/index.js | 9 +++++---- uncompressed/instagram/package.json | 8 +++----- uncompressed/instagram/service.css | 10 ++++++++++ uncompressed/instagram/webview.js | 16 ++++++++++++---- 10 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 icon.png create mode 100644 icon.svg diff --git a/README.md b/README.md index 949d70d..e4c32fc 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,3 @@ Each time you create a new service inside Ferdi, Ferdi will automatically instal ## Creating and adding your own recipes Please refer to our documentation at https://github.com/getferdi/recipes/blob/master/docs/integration.md. - diff --git a/all.json b/all.json index 313624a..d9c51cd 100644 --- a/all.json +++ b/all.json @@ -389,7 +389,7 @@ "featured": false, "id": "instagram", "name": "Instagram", - "version": "1.0.0", + "version": "2.0.0", "icons": { "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/instagram/icon.png", "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/instagram/icon.svg" diff --git a/archives/instagram.tar.gz b/archives/instagram.tar.gz index d86fd80..e9ac967 100644 Binary files a/archives/instagram.tar.gz and b/archives/instagram.tar.gz differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..4b0ef94 Binary files /dev/null and b/icon.png differ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..6575ff6 --- /dev/null +++ b/icon.svg @@ -0,0 +1,29 @@ + + + + instagram + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/uncompressed/instagram/README.md b/uncompressed/instagram/README.md index b8d10f8..0f54f9e 100644 --- a/uncompressed/instagram/README.md +++ b/uncompressed/instagram/README.md @@ -1,3 +1,5 @@ -# Franz Instagram recipe +# Instagram for Ferdi +This is the official Ferdi recipe for Instagram -A Franz recipe for Instagram service. +### How to create your own Ferdi recipes: +* [Read the documentation](https://github.com/getferdi/recipes/blob/master/docs/integration.md) \ No newline at end of file diff --git a/uncompressed/instagram/index.js b/uncompressed/instagram/index.js index b64a3e4..12ff25a 100644 --- a/uncompressed/instagram/index.js +++ b/uncompressed/instagram/index.js @@ -1,7 +1,8 @@ -'use strict' - module.exports = Franz => class Instagram extends Franz { overrideUserAgent() { - return 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B137 Safari/601.1' + return window.navigator.userAgent.replace( + /(Ferdi|Electron)\/\S+ \([^)]+\)/g, + "" + ); } -} \ No newline at end of file +}; diff --git a/uncompressed/instagram/package.json b/uncompressed/instagram/package.json index 639afdb..d245ec7 100644 --- a/uncompressed/instagram/package.json +++ b/uncompressed/instagram/package.json @@ -1,15 +1,13 @@ { "id": "instagram", "name": "Instagram", - "version": "1.0.0", + "version": "2.0.0", "description": "Instagram", "main": "index.js", "author": "Amine Mouafik ", "license": "MIT", - "repository": "https://github.com/getferdi/recipes", "config": { - "hasNotificationSound": false, - "hasIndirectMessages": true, - "serviceURL": "https://www.instagram.com/direct/inbox/" + "serviceURL": "https://instagram.com/direct/inbox", + "hasNotificationSound": true } } diff --git a/uncompressed/instagram/service.css b/uncompressed/instagram/service.css index 8b13789..2cd727c 100644 --- a/uncompressed/instagram/service.css +++ b/uncompressed/instagram/service.css @@ -1 +1,11 @@ +.oYYFH { + padding: 0 !important; +} +.MWDvN, .oYYFH > div { + max-width: 100% !important; +} + +._lz6s { + border-bottom: 0 !important; +} \ No newline at end of file diff --git a/uncompressed/instagram/webview.js b/uncompressed/instagram/webview.js index aede5a5..f4f7f94 100644 --- a/uncompressed/instagram/webview.js +++ b/uncompressed/instagram/webview.js @@ -1,7 +1,15 @@ const path = require("path"); -module.exports = Franz => { - // Apply fixes suggested in - // https://github.com/getferdi/recipes/issues/1 - Franz.injectCSS(path.join(__dirname, "service.css")); +module.exports = (Franz) => { + const getMessages = function getMessages() { + const element = document.querySelector('a[href^="/direct/inbox"]'); + + if (element) { + Franz.setBadge(parseInt(element.innerText, 10)); + } + }; + + Franz.loop(getMessages); + + Franz.injectCSS(path.join(__dirname, 'service.css')); }; -- cgit v1.2.3-54-g00ecf