Skip to content

Instantly share code, notes, and snippets.

@popstas
Last active May 14, 2022 13:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save popstas/9d17c1b0e1772a84581b3af8a342ad73 to your computer and use it in GitHub Desktop.
Save popstas/9d17c1b0e1772a84581b3af8a342ad73 to your computer and use it in GitHub Desktop.
Use og:image as favicon on Gitlab pages
// ==UserScript==
// @name Gitlab project favicon
// @author Stanislav Popov
// @version 0.1
// @namespace popstas.ru
// @description Use og:image as favicon on Gitlab pages
// @unwrap
// @noframes
// @run-at document-end
// @updateURL https://gist.github.com/popstas/9d17c1b0e1772a84581b3af8a342ad73/raw/1f2c562a128568e1b220457bdab1e9d60dc1467d/gitlab-project-favicon.user.js
// @include https://git.viasite.ru/*
// @match https://git.viasite.ru/*
// ==/UserScript==
(function(){
'use strict';
var u ='undefined', win = typeof unsafeWindow !=u ? unsafeWindow: window;
var $ = win.$;
win.onerror = function(error, file, line){
console.log(error +' (line '+line+')');
};
if(win.top != win.self){
return false; // ignore iframes
}
$(function(){
var project_img = $('meta[property="og:image"]').attr('content');
if(project_img){
$('#favicon').attr('href', project_img);
}
});
})();
@slavashvets
Copy link

Looks like it doesn't work in Tampermonkey for Safari

@slavashvets
Copy link

Safari uses tab icons from mask-icon. I've tried to add the following:

$('link[rel="mask-icon"]').attr('href', project_img);

But it doesn't help.

@popstas
Copy link
Author

popstas commented May 14, 2022

Hello, thanks for reminding me about this script ) Just checked, it works same as in 2018. I don't have Mac, so can't fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment