Merge pull request #720 from calzoneman/servicelogin

This resolves an issue where Google returns HTTP200 but provides an H…
This commit is contained in:
Calvin Montgomery 2017-11-28 21:37:28 -08:00 committed by GitHub
commit 60f77d4eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2017-11-27
==========
The Google Drive userscript has been updated once again. Violentmonkey is
now explicitly supported. Google login redirects are caught and handled.
See directly below on how to regenerate the user script again.
2017-11-15 2017-11-15
========== ==========

View File

@ -8,7 +8,7 @@
// @grant GM.xmlHttpRequest // @grant GM.xmlHttpRequest
// @connect docs.google.com // @connect docs.google.com
// @run-at document-end // @run-at document-end
// @version 1.5.0 // @version 1.6.0
// ==/UserScript== // ==/UserScript==
try { try {
@ -80,19 +80,27 @@ try {
var data = {}; var data = {};
var error; var error;
// Google Santa sometimes eats login cookies and gets mad if there aren't any.
if(/accounts\.google\.com\/ServiceLogin/.test(res.responseText)){
error = 'Google Docs request failed: ' +
'This video requires you be logged into a Google account. ' +
'Open your Gmail in another tab and then refresh video.';
return cb(error);
}
res.responseText.split('&').forEach(function (kv) { res.responseText.split('&').forEach(function (kv) {
var pair = kv.split('='); var pair = kv.split('=');
data[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); data[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}); });
if (data.status === 'fail') { if (data.status === 'fail') {
var error = 'Google Drive request failed: ' + error = 'Google Drive request failed: ' +
unescape(data.reason).replace(/\+/g, ' '); unescape(data.reason).replace(/\+/g, ' ');
return cb(error); return cb(error);
} }
if (!data.fmt_stream_map) { if (!data.fmt_stream_map) {
var error = 'Google Drive request failed: ' + error = 'Google Drive request failed: ' +
'metadata lookup returned no valid links'; 'metadata lookup returned no valid links';
return cb(error); return cb(error);
} }
@ -112,7 +120,7 @@ try {
onerror: function () { onerror: function () {
var error = 'Google Drive request failed: ' + var error = 'Google Drive request failed: ' +
'metadata lookup HTTP request failed'; 'metadata lookup HTTP request failed';
error.reason = 'HTTP_ONERROR'; error.reason = 'HTTP_ONERROR';
return cb(error); return cb(error);
} }
@ -206,7 +214,7 @@ try {
'Violentmonkey' // https://github.com/calzoneman/sync/issues/713 'Violentmonkey' // https://github.com/calzoneman/sync/issues/713
]; ];
function isRunningTampermonkey() { function isTampermonkeyCompatible() {
try { try {
return TM_COMPATIBLES.indexOf(GM_info.scriptHandler) >= 0; return TM_COMPATIBLES.indexOf(GM_info.scriptHandler) >= 0;
} catch (error) { } catch (error) {
@ -214,7 +222,7 @@ try {
} }
} }
if (isRunningTampermonkey()) { if (isTampermonkeyCompatible()) {
unsafeWindow.getGoogleDriveMetadata = getVideoInfo; unsafeWindow.getGoogleDriveMetadata = getVideoInfo;
} else { } else {
debug('Using non-TM polling workaround'); debug('Using non-TM polling workaround');
@ -225,7 +233,8 @@ try {
unsafeWindow.console.log('Initialized userscript Google Drive player'); unsafeWindow.console.log('Initialized userscript Google Drive player');
unsafeWindow.hasDriveUserscript = true; unsafeWindow.hasDriveUserscript = true;
unsafeWindow.driveUserscriptVersion = '1.5'; // Checked against GS_VERSION from data.js
unsafeWindow.driveUserscriptVersion = '1.6';
} catch (error) { } catch (error) {
unsafeWindow.console.error(error); unsafeWindow.console.error(error);
} }

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.51.4", "version": "3.51.5",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -1,4 +1,5 @@
var CL_VERSION = 3.0; var CL_VERSION = 3.0;
var GS_VERSION = 1.6; // Google Drive Userscript
var CLIENT = { var CLIENT = {
rank: -1, rank: -1,

View File

@ -3247,11 +3247,15 @@ function maybePromptToUpgradeUserscript() {
return; return;
} }
var currentVersion = [1, 5]; var currentVersion = GS_VERSION.toString(); // data.js
var userscriptVersion = window.driveUserscriptVersion; var userscriptVersion = window.driveUserscriptVersion;
if (!userscriptVersion) { if (!userscriptVersion) {
userscriptVersion = '1.0'; userscriptVersion = '1.0';
} }
currentVersion = currentVersion.split('.').map(function (part) {
return parseInt(part, 10);
});
userscriptVersion = userscriptVersion.split('.').map(function (part) { userscriptVersion = userscriptVersion.split('.').map(function (part) {
return parseInt(part, 10); return parseInt(part, 10);
}); });