Activate Chrome native notifications

For LibNotify, the JSON file that it installs has the incorrect extension ID. Updating the extension ID to the correct one fixes it.

Go to .config/google-chrome/NativeMessagingHosts (for Google Chrome) or .config/chromium/NativeMessagingHosts (for Chromium). Open up the JSON file in the folder, and notice that in the allowed_origins section, it allows the extension ID gphchdpdmccpjmpiilaabhpdfogeiphf. However, the extension ID (at least in my case, but it should be the same for everyone) is actually epckjefillidgmfmclhcbaembhpdeijg.

To fix this, either replace the incorrect extension ID with the correct one, or add a comma and the correct extension ID after it. I personally chose the latter option, and here's what my JSON file looks like:

{
  "name": "com.initiated.chrome_libnotify_notifications",
  "description": "Libnotify Notifications in Chrome",
  "path": path to the location of install.sh,
  "type": "stdio",
  "allowed_origins": [
    "chrome-extension://gphchdpdmccpjmpiilaabhpdfogeiphf/",
    "chrome-extension://epckjefillidgmfmclhcbaembhpdeijg/"
  ]
}

EDIT: That's not the only change that needs to be made. The extension relies on Webkit notifications, which were deprecated and removed in Chrome(ium) and likely other browsers in favor of HTML5 notifications. Therefore, google-chrome/default/Extensions/epckjefillidgmfmclhcbaembhpdeijg/1.0_0/notify_hook.js needs to be updated. I've written a short script for this, but it breaks most of the standard except for displaying the notification. Replace everything in the file with the following (added basic support for sites still using window.webkitNotifications and (hopefully) improved image support) (permissions support added):

OriginalNotification = Notification

Notification = function(title, properties) {
        if (Notification.permission != "granted") {
                if (this.onError) {
                        this.onError();
                }
                return;
        }
        if (!properties.hasOwnProperty("body")) {
                properties["body"] = "";
        }
        if (!properties.hasOwnProperty("icon")) {
                properties["icon"] = "";
        }
        if (properties["icon"]) {
                properties["icon"] = getBaseURL() + properties["icon"];
        }
        document.getElementById('libnotify-notifications-transfer-dom-area').innerText = JSON.stringify({title:title, body:properties["body"], iconUrl:properties["icon"]});
        var event = document.createEvent("UIEvents");
        event.initUIEvent("change", true, true);
        document.getElementById('libnotify-notifications-transfer-dom-area').dispatchEvent(event);
        if (this.onShow) {
                this.onShow();
        }
};

Object.defineProperty(Notification, "permission", {
        get: function() {
                return OriginalNotification.permission;
        },
        set: undefined
});

Notification.requestPermission = function(callback) {
        OriginalNotification.requestPermission(callback);
}

window.webkitNotifications = {}

window.webkitNotifications.checkPermission = function() {
        return 0;
}

window.webkitNotifications.createNotification = function(image, title, body) {
        if (image) {
                image = getBaseURL() + image;
        }
        document.getElementById('libnotify-notifications-transfer-dom-area').innerText = JSON.stringify({title:title, body:body, iconUrl:image});
        var event = document.createEvent("UIEvents");
        event.initUIEvent("change", true, true);
        document.getElementById('libnotify-notifications-transfer-dom-area').dispatchEvent(event);
}

function getBaseURL() {
           return location.protocol + "//" + location.hostname + 
                   (location.port && ":" + location.port) + "/";
}