summaryrefslogtreecommitdiff
path: root/common/browser.js
blob: 582d2a4bb92b38b346a630e77da33c172336d46b (about) (plain)
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
/**
 * This file is part of Haketilo.
 *
 * Function: Export the browser API object.
 *
 * Copyright (C) 2021, 2022 Wojtek Kosior
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the CC0 1.0 Universal License as published by
 * the Creative Commons Corporation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * CC0 1.0 Universal License for more details.
 */

#IF MOZILLA

#EXPORT  globalThis.browser  AS browser

#ELIF CHROMIUM

/* Use promises for sendMessage(). */
function response_cb(resolve, reject, response) {
    if (arguments.length < 3)
	reject(chrome.runtime.lastError);
    else
	resolve(response);
}

function replacement_sendMessage(old_sendMessage, ...args) {
    let callbacks, prom = new Promise((...cbs) => callbacks = cbs);
    old_sendMessage(...args, resp => response_cb(...callbacks, resp));
    return prom;
}

for (const api_object of [chrome.tabs, chrome.runtime].filter(a => a)) {
    const old_sendMessage = api_object.sendMessage;
    api_object.sendMessage =
	(...args) => replacement_sendMessage(old_sendMessage, ...args);
}

#EXPORT  chrome  AS browser

#ENDIF
uix/commit/gnu/packages/kde.scm?id=9d95d8bd120072cb3b983da86baa645c5b2ecd89'>gnu: Add kdiagram....Hartmut Goebel 2020-02-03Merge branch 'staging' into core-updatesMarius Bakke 2020-01-28gnu: Add baloo-widgets....Hartmut Goebel 2020-01-28gnu: Cleanup KDE packages to use the update qt-build-system....Hartmut Goebel 2020-01-15gnu: util-linux: Move libraries to separate output....Marius Bakke 2020-01-12gnu: Use the two-element 'define-deprecated' form where applicable....Ludovic Courtès 2020-01-11gnu: kdevelop: Update to 5.4.6....Tobias Geerinckx-Rice 2019-12-23gnu: Add zeroconf-ioslave....Hartmut Goebel 2019-12-23gnu: Add grantleetheme....Hartmut Goebel 2019-12-23gnu: kdeconnect: Use fixed qt-build-system....Hartmut Goebel 2019-12-23gnu: kdevelop: Use fixed qt-build-system....Hartmut Goebel 2019-12-11gnu: Deprecate kdevplatform package....Hartmut Goebel 2019-12-11gnu: kdevelop: Update to 5.4.5....Hartmut Goebel 2019-12-11gnu: kdevelop-pg-qt: Update to 2.2.0....Hartmut Goebel 2019-12-11gnu: Remove duplicate copyright line....Marius Bakke 2019-12-10gnu: Add libkdegames....Hartmut Goebel 2019-12-04Merge branch 'staging'Marius Bakke 2019-12-01gnu: kdeconnect: Use qt-build-system....Hartmut Goebel 2019-11-28Merge branch 'master' into stagingMarius Bakke 2019-11-28gnu: snorenotify: Update inputs....Efraim Flashner 2019-11-28Merge branch 'master' into stagingMarius Bakke 2019-11-26gnu: kdeconnect: Remove useless code....Hartmut Goebel 2019-11-17gnu: kpmcore: Fix dependencies....Andrius Štikonas 2019-11-15Merge branch 'master' into stagingMarius Bakke 2019-11-10gnu: kpmcore: Update to 4.0.1....Hartmut Goebel 2019-11-10gnu: Move kpmcore to kde.scm....Hartmut Goebel 2019-11-10gnu: krita: Update to 4.2.7.1....Hartmut Goebel 2019-11-10gnu: kqtquickcharts: Update to 19.08.2....Hartmut Goebel 2019-11-10gnu: libkomparediff2: Update to 19.08.2....Hartmut Goebel 2019-11-10gnu: kde-frameworks: Update to 5.63.0....Hartmut Goebel 2019-11-06gnu: Add KCacheGrind....Ludovic Courtès 2019-09-17Merge branch 'master' into core-updatesLudovic Courtès 2019-09-16gnu: Add kqtquickcharts....Efraim Flashner