Open alexkaessner opened 6 years ago
This day had to come, thanks for both the issue and the example link. I'll look into it, it will take some time though. I planned in updating the addon for new years, but that didn't work out, so no idea about the timeframe.
Came here to say this too - just realised how much I need this app today after the redesign ;)
I'm really curious if that problem continues to exist in the future. Apple dropped support for managing iOS apps in iTunes recently and with that it seems iTunes does no longer open. (At least for me, now on 10.13.2 / Safari 11.0.2) This however is not true for Mac AppStore pages like https://itunes.apple.com/us/app/things-3/id904280696?mt=12 (vs iPhone https://itunes.apple.com/us/app/things-3/id904237743?mt=8 or iPad https://itunes.apple.com/us/app/things-3-for-ipad/id904244226?mt=8 )
Could you verify this still happens? If so, which version of macOS and Safari are you using?
I've tested it on macOS 10.13.3 / Safari 11.0.3 and it never opened a Store link outside of Safari at all. Neither the Mac App Store nor the iTunes Store were opened. Of course I had NoMoreiTunes disabled.
Seems like they fixed it by them self 🤷♂️
The same as @alexkaessner but on macOS 10.10.5 / Safari 10.1.2
Digging through the application code of the new App Store pages shows a few traces of code that could be used to open an external application (they basically open a different protocol such as itms://
) but they are out of reach of a regular Safari extension now.
For most apps extension works great but for some it doesn't. And it's not working for music :( Like this link below opens like it should but afer several seconds iTunes is opening as well. https://itunes.apple.com/jp/album/id1343668663 https://itunes.apple.com/jp/album/id1343668663?app=itunes Maybe it's because of this: ?app=itunes? Most sites have link with this additional line
The whole situation is really weird.
I fear that the new pages make it impossible to continue the extension without converting it into an application. The new code does not provide an easy way to replace the method that triggers the launch.
This page – https://itunes.apple.com/us/app/things-3/id904280696?mt=12 – does not open the App Store app (OS X 10.11.6, Safari 11.0.3), only when I actually click on "View in Mac App Store". Whether NoMoreITunes is enabled or disabled, doesn't make a difference.
On Reddit this guy says some links still open Safari: https://www.reddit.com/r/apple/comments/97gpmr/nomoreitunes_alternative/e49fr9g
And the link he gave as an example opens iTunes for me so it seems to still happen sometimes.
The new site has a content security policy that includes the schemes used to open the apps:
itmss: itms-appss: itms-bookss: itms-itunesus: itms-messagess: itms-podcasts: itms-watchs: macappstores: musics: apple-musics:
So by simply removing the schemes you want blocked the browser will do the work for you.
This code blocks the page from opening iTunes:
document.addEventListener("DOMContentLoaded", function () {
let newPolicy = document.querySelector('meta[http-equiv="Content-Security-Policy"]').getAttribute("content").replace("itmss: ", "");
document.querySelector('meta[http-equiv="Content-Security-Policy"]').setAttribute("content", newPolicy);
}, false);
If you open the console you can see where the browser blocks the request:
Refused to load itmss://itunes.apple.com/us/album/queen/1398449449?affC=QQAJAAAACwBFOpwGMTBsNmk5AAAAAFNapSk%3D&app=itunes&ign-refClientId=3z1rBLsQz8hlz5Hrz9foz73fMmjux because it does not appear in the frame-src directive of the Content Security Policy.
I'm probably going to pack this up into a Safari App Extension since Apple is deprecating these legacy extensions.
EDIT:
Here is the final version of the script basically:
document.addEventListener("DOMContentLoaded", function () {
if (location.href.indexOf("launch=true") == -1) {
//Remove the schemes we want to block from the CSP. (https://github.com/pichfl/NoMoreiTunes/issues/15#issuecomment-413724332)
let newPolicy = document.querySelector('meta[http-equiv="Content-Security-Policy"]').getAttribute("content").replace(" itmss:", "").replace(" macappstores:", "");
document.querySelector('meta[http-equiv="Content-Security-Policy"]').setAttribute("content", newPolicy);
//Handle the "View in Mac App Store"/"Listen on Apple Music" button
document.addEventListener("click", function (event) {
if (event.target.className == "we-button__app-text" || event.target.children[0].className == "we-button__app-text") {
event.stopPropagation();
location.href = "?launch=true"; //We redirect to the same page but with a new URL param
}
}, false);
} else {
//This new page doesn't have the shemes blocked so we can now open the desired app
location.href = (document.querySelector(".we-button__app-text").innerText == "Mac App Store" ? "macappstores" : "itmss") + "://" + location.host + location.pathname;
setTimeout(function () {
//Lil user friendlyness so that people won't go around copy and pasting "?launch=true" links
window.history.go(-1);
}, 1000)
}
}, false);
I've tested this in both a native Safari App Extension and a legacy extension.
This also allows the user to click on the "View in Mac App Store"/"Listen on Apple Music" button already on Apple's site to open the correct application.
Dude, that is genius. Since legacy extensions will indeed be phased out would you be interested in joining this repository to develop a new one under the same name?
Yeah sure you can add me to this repository.
I'm not sure how releasing an app extension works, I know that you have to release a ".app". Problem with having to release a .app is the signing. Xcode doesn't let you export the app if you code sign with an account not in the Apple Developer Program. So if you set it to not code sign you're able to export it but I can't get any of my exported versions to actually install the extension to Safari.
You're supposed to be able to open the .app and the extension automatically gets installed to Safari. I wanna say this has something to do with Safari not allowing unsigned extensions. (But even if I set it to allow them in the develop menu it still seems to not work)
Apple's documentation on this stuff seems to be lacking, but maybe I'm just not looking in the right places.
Possibly useful info: https://stackoverflow.com/a/42775751
And also there would be no way to update the extension unless we either pay to get on the Mac App Store or handle updating using some updating library, because thanks Apple?
I can take care of the signing, ever since creating this extension and working on other projects I have to keep my dev account active anyways. Publishing on the App Store is totally an option.
We probably won't make it into the App Store though, given I never managed to get the Extension into the Gallery either. But signing the app for release and download here on GitHub could work I guess.
Alright you can sign it great.
And yeah I doubt we'd make it to the App Store. We can just have it check GitHub for an update (https://github.com/pichfl/NoMoreiTunes/releases) and tell the user they need to update. Cause autoupdating would add quite a bit of complexity and just seems kinda pointless for something small like this.
You want me to make a pull request for this or just add me to this repository?
A PR would be nice. I began looking into the update thing as well and it look like we could consider Sparkle for the app and have some script that bridges to GitHub releases. I’ll try to get the old website up and running again
I've now switched to Firefox anyway, but I'll see if I can get the above script to work in Tampermonkey.
Apple just pushed a redesigned web preview for the app store. Sadly this broke NoMoreiTunes 😕 I'm "using" this extension every day (yes I check out a lot apps). Please update it again! ❤️
PS: If you need a quick app store link to check out the problem, feel free to check out my latest app ¯_(ツ)_/¯ example App Store link