Fix: batch lock failed w/ secondary Google Accounts
This change fixes this issue, as part of the efforts to support users
who use the Community Console with secondary Google Accounts.
Change-Id: I8f0ce8f36a851c7b0db85e01a736b15acba4feef
diff --git a/src/injections/batchlock_inject.js b/src/injections/batchlock_inject.js
index 1b5bb48..3ffd298 100644
--- a/src/injections/batchlock_inject.js
+++ b/src/injections/batchlock_inject.js
@@ -20,6 +20,12 @@
return undefined;
}
+function returnAuthUser() {
+ var startup =
+ JSON.parse(document.querySelector('html').getAttribute('data-startup'));
+ return startup[2][1] || '0';
+}
+
// Source:
// https://stackoverflow.com/questions/33063774/communication-from-an-injected-script-to-the-content-script-with-a-response
var contentScriptRequest = (function() {
@@ -116,6 +122,11 @@
modal.querySelector('main').textContent = '';
modal.querySelector('main').append(p, log);
+ var authuser = returnAuthUser();
+ var APIRequestUrl =
+ 'https://support.google.com/s/community/api/SetThreadAttribute' +
+ (authuser == '0' ? '' : '?authuser=' + encodeURIComponent(authuser));
+
checkboxes.forEach(checkbox => {
var url = recursiveParentElement(checkbox, 'A').href;
var thread = parseUrl(url);
@@ -123,7 +134,7 @@
console.error('Fatal error: thread URL ' + url + ' could not be parsed.');
return;
}
- fetch('https://support.google.com/s/community/api/SetThreadAttribute', {
+ fetch(APIRequestUrl, {
'headers': {
'content-type': 'text/plain; charset=utf-8',
},