Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since v4.18.1 yesterday, Scripts don't always execute / TM doesn't match scripts to page consistently #1680

Closed
DerekZiemba opened this issue Jan 10, 2023 · 2 comments

Comments

@DerekZiemba
Copy link

DerekZiemba commented Jan 10, 2023

Expected Behavior

To consistently execute the script that matches the website and show the scripts that match a website in the extension menu.

image

Actual Behavior

Every once in a while, so far seemingly randomly, no script loads. Tampermonkey appears to fail to match available scripts to the page (no scripts are shown in the dropdown menu). Refreshing the page gets it working again. Can't replicate it consistently. The amount of tabs in this screenshot is how many tries it took to trigger the issue.
image

The error in the console is from Tampermonkey

Uncaught Error: pagejs missing. Please see http://tmnk.net/faq#Q208 for more information.
chrome-extension://iikmkjmpaadaobahmlepeloendndfphd\4.18.1_0\content.js

It doesn't seem to be unique to reddit, I've also encountered the issue with my Youtube & Coinbase scripts.

Specifications

  • Microsoft Edge Version 108.0.1462.76 (Official build) (64-bit)
  • TM: 4.18.1_0
  • OS: Win10 21H2 19044.2364

Script

My scripts are way too long. But they're basically like this:

// ==UserScript==
// @name         RESEnhancementScript-2
// @version      2.0.0
// @description	 Enhance RedditEnhancementSuite
// @author       Derek Ziemba
// @match        *://*.reddit.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @noframes
// @nocompat
// @run-at	    document-start
// @grant           GM_getResourceText
// @grant           GM_addStyle
// @grant           GM_addElement
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_deleteValue
// @grant           GM_listValues
// @grant           GM_addValueChangeListener
// @grant           GM_removeValueChangeListener
// @grant           GM_log
// @grant           GM_info
// @grant           GM_registerMenuCommand
// @grant           GM_unregisterMenuCommand
// @grant           GM_xmlhttpRequest
// @grant           window.close
// @grant           window.onurlchange
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/GM.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/RetroEvents.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/WaitFor.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/DeferredAction.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/Debouncer.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/core/Batcher.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/reddit-base.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/config.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/mainMenu.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/SublinksBar.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/ScrollingSideBars.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/ContinueThisThread.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/FilterRule.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/rules.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/Thing.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/LinkRegistry.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/ListingManager.js
// @require                 file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/reddit.js
// @resource   STYLE        file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/reddit.css
// @resource   TEMPLATES    file:///A:/Dropbox/Scripts/.js/ZZ/site/reddit/reddit.html
// ==/UserScript==

/**
  All my scripts first @require file:///A:/Dropbox/Scripts/.js/ZZ/core/GM.js
  Basically creates my environment (common functions) and hacks in 'require', 'module', & 'exports' functionality
  This is basically the start of that file (2069 lines long)
*/
GM = ((/**@type {GreaseMonkey.IGM}*/powers, /**@type {UnsafeWindow}*/unsafeWindow)=>{
  return {
    // This my workaround after your update broke my scripts. 
    // I see you removed `powers` 
    //   and introduced a `GM` variable with async equivalents of the `GM_*` functions?
    // I was already using the 'GM' variable so that hurt a little bit. 
    addStyleAsync: powers.addStyle,
    addElementAsync: powers.addElement,
    getResourceTextAsync: powers.getResourceText,
    logAsync: powers.log,
    infoAsync: powers.info,
    listValuesAsync: powers.listValues,
    getValueAsync: powers.getValue,
    setValueAsync: powers.setValue,
    deleteValueAsync: powers.deleteValue,
    addValueChangeListenerAsync: powers.addValueChangeListener,
    removeValueChangeListenerAsync: powers.removeValueChangeListener,
    registerMenuCommandAsync: powers.registerMenuCommand,
    unregisterMenuCommandAsync: powers.unregisterMenuCommand,
    xmlhttpRequestAsync: powers.xmlhttpRequest,
    addStyle: typeof GM_addStyle !== 'undefined' ? GM_addStyle : powers.addStyle,
    addElement: typeof GM_addElement !== 'undefined' ? GM_addElement : powers.addElement,
    getResourceText: typeof GM_getResourceText !== 'undefined' ? GM_getResourceText : powers.getResourceText,
    log: typeof GM_log !== 'undefined' ? GM_log : powers.log,
    info: typeof GM_info !== 'undefined' ? GM_info : powers.info,
    listValues: typeof GM_addStyle !== 'undefined' ? GM_listValues : powers.listValues,
    getValue: typeof GM_getValue !== 'undefined' ? GM_getValue : powers.getValue,
    setValue: typeof GM_setValue !== 'undefined' ? GM_setValue : powers.setValue,
    deleteValue: typeof GM_deleteValue !== 'undefined' ? GM_deleteValue : powers.deleteValue,
    addValueChangeListener: typeof GM_addValueChangeListener !== 'undefined' ? GM_addValueChangeListener : powers.addValueChangeListener,
    removeValueChangeListener: typeof GM_removeValueChangeListener !== 'undefined' ? GM_removeValueChangeListener : powers.removeValueChangeListener,
    xmlhttpRequest: typeof GM_xmlhttpRequest !== 'undefined' ? GM_xmlhttpRequest : powers.xmlhttpRequest,
    registerMenuCommand: typeof GM_registerMenuCommand !== 'undefined' ? GM_registerMenuCommand : powers.registerMenuCommand,
    unregisterMenuCommand: typeof GM_unregisterMenuCommand !== 'undefined' ? GM_unregisterMenuCommand : powers.unregisterMenuCommand,
  };
  /**@ts-ignore*/
})(GM, typeof unsafeWindow !== 'undefined' ? unsafeWindow : globalThis??window);

Object.defineProperty(unsafeWindow, 'GM', { configurable: true, value: GM });

/**
  Here I create my own 'require', 'module', & 'exports' functions 
    as well as various helper functions. 

  Then the remaining scripts that were @require'd get appended
*/
@derjanb
Copy link
Member

derjanb commented Jan 10, 2023

Uncaught Error: pagejs missing. Please see http://tmnk.net/faq#Q208 for more information.

Have you tried the steps mentioned there?

Duplicate of #1617

@derjanb derjanb closed this as completed Jan 10, 2023
@DerekZiemba
Copy link
Author

As mentioned in the linked issue, I:

  • disabled Tampermonkey
  • restarted Edge for good measure
  • enabled Tampermonkey
  • restarted Edge again for good measure

Have yet to have it occur again. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants