From 85169fbb5678579fdf44018cc4a50ca845c0459f Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Wed, 15 Nov 2017 22:27:31 -0800 Subject: [PATCH] Update drive userscript (#714) --- NEWS.md | 8 ++++++++ gdrive-userscript/cytube-google-drive.user.js | 11 ++++++++--- package.json | 2 +- www/js/util.js | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index cb95323c..0eb5a0d9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +2017-11-15 +========== + +The Google Drive userscript has been updated due to breaking changes in +Greasemonkey 4.0. Remember to generate the script by running: + + $ npm run generate-userscript "Your Site Name" http://your-site.example.com/r/* + 2017-11-05 ========== diff --git a/gdrive-userscript/cytube-google-drive.user.js b/gdrive-userscript/cytube-google-drive.user.js index 2d094956..e2efe323 100644 --- a/gdrive-userscript/cytube-google-drive.user.js +++ b/gdrive-userscript/cytube-google-drive.user.js @@ -3,11 +3,13 @@ // @namespace gdcytube // @description Play Google Drive videos on {SITENAME} // {INCLUDE_BLOCK} +// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js // @grant unsafeWindow // @grant GM_xmlhttpRequest +// @grant GM.xmlHttpRequest // @connect docs.google.com // @run-at document-end -// @version 1.3.0 +// @version 1.4.0 // ==/UserScript== try { @@ -56,7 +58,7 @@ try { + '&hl=en'; debug('Fetching ' + url); - GM_xmlhttpRequest({ + GM.xmlHttpRequest({ method: 'GET', url: url, onload: function (res) { @@ -100,6 +102,9 @@ try { error.reason = 'HTTP_ONERROR'; return cb(error); } + }).catch(function (error) { + error.reason = 'GM.xmlHttpRequest error'; + return cb(error); }); } @@ -204,7 +209,7 @@ try { unsafeWindow.console.log('Initialized userscript Google Drive player'); unsafeWindow.hasDriveUserscript = true; - unsafeWindow.driveUserscriptVersion = '1.3'; + unsafeWindow.driveUserscriptVersion = '1.4'; } catch (error) { unsafeWindow.console.error(error); } diff --git a/package.json b/package.json index 7fdf8f35..5f98bbd4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.51.3", + "version": "3.51.4", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/www/js/util.js b/www/js/util.js index 98d88c8a..594c2a92 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -3247,7 +3247,7 @@ function maybePromptToUpgradeUserscript() { return; } - var currentVersion = [1, 3]; + var currentVersion = [1, 4]; var userscriptVersion = window.driveUserscriptVersion; if (!userscriptVersion) { userscriptVersion = '1.0';