Skip to content

Commit

Permalink
added random user agent strings
Browse files Browse the repository at this point in the history
No matter what I do, I can either fix the google login issue OR I can fix links not working, but none of the fixes every seemed to want to work on their own...
  • Loading branch information
Adondriel committed Mar 3, 2020
1 parent 9d5a34b commit adfee39
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ This is the official Franz recipe for Gmail

### How to create your own Franz recipes:
* [Read the documentation](https://github.com/meetfranz/plugins)

### Known Issues:
* If you add a new google service, and do not login before restarting Franz, the service will go to the wrong url and you will not be able to login.
* If this happens, just delete the service and try again.
57 changes: 53 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,59 @@
"use strict";

// module.exports = Franz => Franz;
module.exports = Franz => class Gmail extends Franz {
overrideUserAgent() {
const userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36";
events = {
'new-window': 'newWindow',
'dom-ready': 'domReady'
}

domReady(e) {
const loadedUrl = e.target.src;
if (loadedUrl && loadedUrl.includes('https://www.google.com/gmail/about')) {
this.loadURL('https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/');
}

// if (loadedUrl && loadedUrl.includes('https://myaccount.google.com')) {
// this.loadURL(this.serviceURL)
// }
console.info('domReady: ', loadedUrl);
console.info('domReady: ', e);
}

newWindow(event) {
console.info('gmail-new-window: ', event);
const newUrl = event.url;
const oldUrl = event.path[0].src;

event.preventDefault();

if (newUrl && oldUrl) {
this.send('new-window', newUrl);
}
}

overrideUserAgent() {
const userAgent = this.getRandomUserAgent();
console.info('ua: ', userAgent);
return userAgent;
}

getRandomUserAgent() {
const uaList = [
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
// 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36',
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36',
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
// 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
'Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 Edge/12.10136',
'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 Edg/12.10136',
'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36 Edge/12.10136'
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134',
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763',
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393',
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063',
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362',
// 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136'
];
return uaList[Math.floor(Math.random() * uaList.length)]
}
};
18 changes: 17 additions & 1 deletion webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = Franz => {
const getMessages = function getMessages() {
events = {
'new-window': 'newWindow'
};

function newWindow(event) {
console.info('gmail-new-window: ', event);
const newUrl = event.url;
const oldUrl = event.path[0].src;

event.preventDefault();

if (newUrl && oldUrl) {
this.send('new-window', newUrl);
}
}

function getMessages() {
let count = 0;

if (document.getElementsByClassName('J-Ke n0').length > 0) {
Expand Down

0 comments on commit adfee39

Please sign in to comment.