[Unsupported] App Store script

It doesn’t work for me (Chromium 65.0.3325.162 (Developer Build) (64-bit)) too. I get 404 page. The information I was able to gather:

There’s an issue on Tampermonkey, which says:

Unfortunately this is intentionally not supported by Chrome. :frowning:

Chrome extension docs says:

A match pattern is essentially a URL that begins with a permitted scheme (http, https, file, or ftp, and that can contain ‘*’ characters. The special pattern <all_urls> matches any URL that starts with a permitted scheme.

For about:blank they have a separate property.

There’s also this thread on reddit, that points to this extension. It does the following:

manifest.json:

    ...
    "background": {
        "scripts": [
            "modErrorPage.js"
        ]
    },
    ...

modErrorPage.js:

var oldPageErrorDetails = false;

//Adding a Listener to Error Occured Event
chrome.webNavigation.onErrorOccurred.addListener(function(details) {
    if (details && details.url && details.frameId === 0 &&
        details.error != 'net::ERR_ABORTED') {
        oldPageErrorDetails = details;
        //console.log(details);
        // Updating the browser window with desired URL
        chrome.tabs.update(details.tabId, {
            url: chrome.extension.getURL("ErrorPageEnhanced.html?url=" + encodeURIComponent(details.url) + '&error=' + encodeURIComponent(details.error))
        });
    }
});

Not sure if that helps…

And when I add an alert to the beginning of the script, it shows anywhere but on error pages.

Not sure if it’s a good place for this, but here’s the patch:

--- 1.js	2018-03-17 18:24:02.587006488 +0200
+++ 2.js	2018-03-17 18:24:03.750006543 +0200
@@ -18,7 +18,36 @@
     var scripts;
     var uuid;
 
-    if (window.location.pathname.indexOf('/script/appStore') === 0) {
+    // https://stackoverflow.com/a/8649003/52499
+    function qs() {
+        var search = location.search.substr(1);
+        return search.length ? JSON.parse(
+            '{"'
+                + location.search.substr(1)
+                .replace(/&/g, '","')
+                .replace(/=/g,'":"')
+            + '"}',
+            function(key, value) {
+                return key===""?value:decodeURIComponent(value)
+            })
+        : {};
+    }
+
+    // https://stackoverflow.com/a/1714899/52499
+    function sq(qs) {
+        var str = [];
+        for (var p in qs)
+            if (qs.hasOwnProperty(p)) {
+                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(qs[p]));
+            }
+        return str.join("&");
+    }
+
+    function genUrl(page) {
+        return location.pathname + '?' + sq(Object.assign(qs(), {asp: page}));
+    }
+
+    if (qs()['asp']) {
         renderAppStore();
     } else {
         setUuid();
@@ -44,7 +73,7 @@
 
     function renderHooks() {
         // Hook into App Store
-        $('<li class="app-store-menu-item-actual"><a href="/script/appStore">App Store</a></li>').insertBefore($('.navbar .dropdown-menu .nav-header:contains("Account")'));
+        $('<li class="app-store-menu-item-actual"><a href="' + genUrl('index') + '">App Store</a></li>').insertBefore($('.navbar .dropdown-menu .nav-header:contains("Account")'));
 
         var css =
             '.app-store-menu-item { display: none; }'+
@@ -107,6 +136,9 @@
 '    var globalVariables = {};'+
 '    var scripts;'+
             ' var uuid;'+
+                              qs.toString()+"\n"+
+                              sq.toString()+"\n"+
+                              genUrl.toString()+"\n"+
                               renderPage.toString()+"\n"+
                               init.toString()+"\n"+
                               get_api_key.toString()+"\n"+
@@ -133,19 +165,19 @@
                 '          <h1>App Store</h1>'+
                 '        </li>'+
                 '        <li class="new">'+
-                '          <a href="/script/appStore/new"><span><div class="octicon"></div></span><span>New</span></a>'+
+                '          <a href="' + genUrl('new') + '"><span><div class="octicon"></div></span><span>New</span></a>'+
                 '        </li>'+
                 '        <li class="top-charts">'+
-                '          <a href="/script/appStore/top"><span><div class="octicon"></div></span><span>Top Charts</span></a>'+
+                '          <a href="' + genUrl('top') + '"><span><div class="octicon"></div></span><span>Top Charts</span></a>'+
                 '        </li>'+
                 '        <li class="categories">'+
-                '          <a href="/script/appStore/categories"><span><div class="octicon"></div></span><span>Categories</span></a>'+
+                '          <a href="' + genUrl('categories') + '"><span><div class="octicon"></div></span><span>Categories</span></a>'+
                 '        </li>'+
                 '        <li class="installed">'+
-                '          <a href="/script/appStore/installed"><span><div class="octicon"></div></span><span>Installs</span></a>'+
+                '          <a href="' + genUrl('installed') + '"><span><div class="octicon"></div></span><span>Installs</span></a>'+
                 '        </li>'+
                 '        <li class="search">'+
-                '          <a href="/script/appStore/search"><span><div class="octicon"></div></span><span>Search</span></a>'+
+                '          <a href="' + genUrl('search') + '"><span><div class="octicon"></div></span><span>Search</span></a>'+
                 '        </li>'+
                 '      </ul>'+
                 '<ul class="nav pull-right">'+
@@ -161,7 +193,7 @@
                 '        <a href="/dashboard">Dashboard</a>'+
                 '      </li><li>'+
                 '        <a href="https://community.wanikani.com">Community</a>'+
-                '      <li class="app-store-menu-item-actual"><a href="/script/appStore">App Store</a></li><li class="nav-header">'+
+                '      <li class="app-store-menu-item-actual"><a href="' + genUrl('index') + '">App Store</a></li><li class="nav-header">'+
                 '        Account'+
                 '      </li><li>'+
                 '        <a href="/users/hitechbunny">Profile</a>'+
@@ -249,8 +281,7 @@
                     var alreadyRendered = {};
 
                     var sections = [];
-                    var page = window.location.pathname.split('/');
-                    page = page[page.length-1];
+                    var page = qs()['asp'];
 
                     var generalRanking = function(s) { return s.likes + (s.img_url ? 300 : 0) + (s.percentage_of_users > 0 ? 100*s.percentage_of_users : 0); };
                     if (page == 'top') {

Anyone else having issues with this?

The author of this script has been MIA for months and their scripts, which use the author’s private server to run, has been going down periodically. I saw that someone thinking that another of Hitech’s scripts had gone down for good, but we’ll see. In either case it’s probably not just you. I’ll mark the thread as unsupported for now.

Help. I don’t know why or how but this script is piggy backing off my other scripts! I don’t have the script anymore and haven’t for a while but the app store options is still there. One the one it’s doing it off (could be multiple) I reinstalled it and it’s still doing it.

The recommended “hook” in the OP (when other scripts should appear in the app store) adds the menu item, but clicking it only brings you to this forum here. The script itself is not doing anything on your PC.

You just have at least one script installed that was using the store.

You have to go into the code of each of your scripts and comment out any lines that add the App Store link.

According to Google Developers article, you can:

  • Use asynchronous script loading, using <script src="..." async> or element.appendChild() ,

It is better don’t use document.write for jQuery CDN, here is workaround:

var script = document.createElement('script');  
script.src = "....";  
document.head.appendChild(script);
1 Like