Last active
January 30, 2023 21:27
-
-
Save banderson623/81889e7764da84f32112 to your computer and use it in GitHub Desktop.
Use native notification center for Slack in fluid.app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var clickOverrides = function(){ | |
// Automatically mark ALL as read and scroll to it | |
// when clicking on a channel (stared or normal) | |
$('#channel-list, #starred-list').on('click',function(){ | |
TS.ui.forceMarkAllRead(); | |
TS.ui.scrollMsgsSoFirstUnreadMsgIsInView(); | |
}); | |
}; | |
var onMessageClick = function(){ | |
TS.ui.forceMarkAllRead(); | |
TS.ui.scrollMsgsSoFirstUnreadMsgIsInView(); | |
}; | |
// Setup and use notification center! Yay. | |
function wkNotify(title,content,clickCallBack) { | |
if (!window.Notification) { | |
console.log('not supported'); | |
return; | |
} | |
if (Notification.permission === 'denied') { | |
console.log("Can't show notification here"); | |
} else if (Notification.permission === 'default') { | |
// Get permission | |
Notification.requestPermission(function() { | |
notify(); | |
}); | |
} else if (Notification.permission === 'granted') { | |
var wkNotification = window.webkitNotifications.createNotification(null, title, content); | |
if(typeof clickCallBack === "function"){ | |
wkNotification.onclick = clickCallBack; | |
} | |
// Show that thing! | |
try {wkNotification.show();} | |
catch (e) {alert('error: '+e);} | |
} | |
} | |
// override the growl and use notification center | |
// wait 10 seconds for everything to load, then do this | |
setTimeout(function(){ | |
clickOverrides(); | |
wkNotify("Loaded custom scripts",""); | |
TS.ui.growls.show = function(title, text, a,b,c){ | |
wkNotify(title,text,onMessageClick); | |
}; | |
},10000); |
how do I use this?
is it posible that u made the same but for gmail in fluid app please ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
are you still using this? I'm pretty upset with the native slack app performance.