How to add desktop shortcut for URL, ignoring web app manifest?


Question

Goal: Have a desktop shortcut that opens https://news.google.com/news/i#0 , ignoring the contained web app manifest that otherwise "overrides" the saved shortcut to http://news.google.com/news?sapa=1 and with "display": "standalone".



I had this working previously on an older Android phone before a replacement / upgrade.



Prior to the upgrade, I was able to long-press and open individual articles in new tabs - as well as copy link shortcuts to specific articles, as well as all of the other features and functionality that Chrome has to offer. Here is just a partial selection of references of other users complaining about the same:





Using https://news.google.com/news/i#0 provides a temporary successful work-around. However, I can't find a successful way to add a link for this to my home screen. The "Add to Home screen" option within Chrome instead saves a link to http://news.google.com/news?sapa=1 - and in such a way that it opens as a web application instead of a web page within Chrome:





On a desktop operating system, this would be a non-issue. (Create shortcut, enter desired URL, done.)



Attempt 1: Provide my own Manifest



So I created my own manifest - editing https://news.google.com/news/ui/resources/json/manifest.json to change the start_url attribute to https://news.google.com/news/i#0, and the display attribute from standalone to browser. I then created my own HTML page that simply contained the below - then self-hosted both on a local web server:



<html>
<head>
<Title>Google News</Title>
<link rel="manifest" href="/news/manifest.json"/>
</head>
<body>
Test
</body>
</html>


However, this doesn't work: Despite the shortcut being saved with the desired name and icon, it links back to my self-hosted HTML page, and not the indicated start_url. Unfortunately, it appears that cross-domain URLs are not allowed per the manifest intent - as per https://github.com/w3c/manifest/issues/183 and https://github.com/w3c/manifest/issues/196 .



Attempt 1b: MITM website



Within the confines of my own local network, I figured I could try to man-in-the-middle (MITM) the website to temporarily provide a desired manfiest to use for addition to the home screen. Unfortunately, the website uses HSTS here, which appropriately blocks the attempt.



Regardless - this is way too much work for what should be a simple effort.



Attempt 2: Widget Bookmark



Unfortunately, it looks like the 1x1 bookmark widget was removed in Chrome 48, as per https://productforums.google.com/forum/#!topic/chrome/Ikn2YhvT98s . The suggested work-around is to use the "Add to Home screen" feature within Chrome. Goto 10 / see beginning.



Attempt 3: Use the default-provided "Internet" browser



Unfortunately, using "Add shortcut on Home screen" in the default-provided "Internet" browser produces the same result as Chrome.



Consideration 4: Use a custom app / widget



Could probably write and install a custom application or widget that could be added to the home screen to meet the goal.



Or don't re-invent the wheel, and use an existing one. Some possibilities:





Conclusion



How can someone create a desktop shortcut to an arbitrary URL, ignoring a provided web app manifest?


Answer



To bypass any site's web app manifest...






    1. Copy the following code...




        JavaScriptx:

        if (meta=document.querySelector('meta[name="mobile-web-app-capable"]')) meta.parentNode.removeChild(meta);

        if (mani=document.querySelector('link[rel="manifest"]')) mani.parentNode.removeChild(mani);

        void(0)




    2. Open Chrome on Android

    3. Go to the URL you want to add to your Home screen, for example...



    4. Paste the code copied earlier into Chrome's Location bar

    5. Scroll to the beginning of the pasted code

        (Touch & Drag repeatedly on the text in the Location bar to scroll it)


    6. Touch after the x in JavaScriptx
    7. Backspace the x, using whatever your Backspace button looks like on the on-screen keyboard
    8. Touch Go on the on-screen keyboard (to confirm/accept the URL & run it)




    The JavaScript should execute on the page & it should appear to do nothing, that's fine.



      Note: if the page reloads for any reason, you'll need to run the JavaScript again.



    Now, try adding that page to the Home screen again...


To add the URL to the Home screen...






    1. Touch Chrome's on-screen "3 dots menu" (on the right of the Location bar, next to the "open tab count" button) or use the hardware menu button


    2. Touch Add to Home screen




    It should end up as a normal Chrome link, not as a Web App, since the JavaScript nuked the page's preference for "web app mode".


Questions / Comments?...




    Why did you have me copy JavaScriptx...just to have me Backspace the x off later?



      Because, in my testing, on my phone, when I pasted anything with JavaScript: at the beginning, Chrome ripped that part off, leaving only the text after it.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes