Добавляет через айтюнс кнопку на apps.apple.com
// ==UserScript==
// @name Открытие приложений App Store через iTunes
// @namespace https://4pda.to/forum/index.php?showtopic=554020
// @version 1.0
// @description Добавляет через айтюнс кнопку на apps.apple.com
// @author 4pda_users
// @match https://apps.apple.com/*/app/*
// @grant none
// @run-at document-end
// @license MIT
// @name:en Open AppStore apps by iTunes
// @description:en Adds to itunes button in apps.apple.com
// ==/UserScript==
(function() {
'use strict';
function addItunesButton() {
const buttonsContainer = document.querySelector('div.buttons-container');
if (!buttonsContainer) return;
if (buttonsContainer.querySelector('.itunes-button')) return;
const shareButton = buttonsContainer.querySelector('button[aria-label*="Поделиться"], button[aria-label*="Share"]');
if (!shareButton) return;
const itunesButton = shareButton.cloneNode(true);
itunesButton.className = shareButton.className + ' itunes-button';
itunesButton.setAttribute('aria-label', 'Открыть в iTunes');
itunesButton.innerHTML = `
<svg width="35.000000pt" height="35.000000pt" viewBox="0 0 35.000000 35.000000">
<g transform="translate(0.000000,45.000000) scale(0.100000,-0.100000)" fill="#FFFFFF" stroke="none">
<path d="M170 427 c-78 -25 -140 -129 -127 -212 14 -87 65 -144 150 -166 147 -40 279 98 237 248 -31 107 -147 166 -260 130z m150 -40 c51 -27 90 -90 90 -147 0 -87 -83 -170 -170 -170 -87 0 -170 83 -170 170 0 20 10 56 23 80 27 51 90 90 147 90 20 0 56 -10 80 -23z"></path>
<path d="M235 347 l-50 -12 -3 -66 c-3 -59 -5 -67 -27 -77 -27 -13 -32 -31 -13 -50 35 -35 68 3 68 78 0 32 3 61 8 63 4 2 24 7 45 11 37 7 37 7 37 -27 0 -26 -6 -36 -25 -45 -28 -13 -32 -34 -10 -52 20 -16 54 -3 60 23 4 12 5 54 3 92 -3 80 -6 82 -93 62z"></path>
</g>
</svg>
iTunes
`;
itunesButton.onclick = function(e) {
e.preventDefault();
e.stopPropagation();
const currentUrl = window.location.href;
const itunesUrl = currentUrl.replace('https://', 'itms://');
window.location.href = itunesUrl;
setTimeout(() => {
if (window.location.protocol !== 'itms:') {
window.open(itunesUrl, '_blank');
}
}, 1000);
};
shareButton.parentNode.insertBefore(itunesButton, shareButton.nextSibling);
}
setTimeout(addItunesButton, 1000);
const observer = new MutationObserver(() => {
if (!document.querySelector('.itunes-button')) {
setTimeout(addItunesButton, 500);
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();