File: content-script-start.js

package info (click to toggle)
chrome-gnome-shell 10.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,440 kB
  • sloc: python: 444; sh: 18; makefile: 11
file content (63 lines) | stat: -rw-r--r-- 1,804 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
    GNOME Shell integration for Chrome
    Copyright (C) 2016  Yuri Konotopov <ykonotopov@gnome.org>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 */

/*
 * Hijack require property to disallow execution of main extensions.gnome.org
 * script until extension initializated.
 */

var gs_require_inject = function () {
	GS_CHROME_ID		= "${GS_CHROME_ID}";
	GS_CHROME_VERSION	= "${GS_CHROME_VERSION}";
};

var siteMessages = {};
if(EXTERNAL_MESSAGES)
{
	for(var key in EXTERNAL_MESSAGES)
	{
		siteMessages[EXTERNAL_MESSAGES[key]] = chrome.i18n.getMessage(EXTERNAL_MESSAGES[key]);
	}
}

var s = document.createElement('script');

s.type = "text/javascript";
s.textContent = '(' +
	gs_require_inject.toString()
		.replace("${GS_CHROME_ID}", GS_CHROME_ID)
		.replace("${GS_CHROME_VERSION}", chrome.runtime.getManifest().version)
	+ ")(); GSC = {i18n: JSON.parse('" + JSON.stringify(siteMessages).replace(/'/g, "\\'") + "')};";
(document.head||document.documentElement).appendChild(s);
s.parentNode.removeChild(s);

chrome.runtime.onMessage.addListener(
	function (request, sender, sendResponse) {
		if(
			sender.id && sender.id === GS_CHROME_ID &&
			request && request.signal && [SIGNAL_EXTENSION_CHANGED, SIGNAL_SHELL_APPEARED].indexOf(request.signal) !== -1)
		{
			window.postMessage(
				{
					type: "gs-chrome",
					request: request
				}, "*"
			);
		}
	}
);

s = document.createElement('script');

s.src = chrome.extension.getURL('include/sweettooth-api.js');
s.onload = function() {
    this.parentNode.removeChild(this);
};
(document.head || document.documentElement).appendChild(s);