Skip to content

trusted-click-element does not re-trigger after SPA navigation #4126

Description

@JoviDong

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • using a new, unmodified browser profile.

Description

I'm using trusted-click-element to auto-click the high-quality "trial mode" toast on Bilibili for unlogged users.

www.bilibili.com##+js(trusted-click-element, '.bpx-player-toast-wrap .bpx-player-toast-confirm-login, .bpx-player-control-wrap .bpx-player-ctrl-quality-menu-wrap .bpx-player-ctrl-quality-menu-item[data-value="80"]', !cookie:/^DedeUserID=/)

The primary issue is that trusted-click-element only triggers once. It works perfectly on the first video, but when clicking a new video on the same page (SPA navigation), the scriptlet fails to click the new toast.

To test this, I used a Violentmonkey script to hook Object.defineProperty and Object.defineProperties to force-enable the trial mode for every video (since set-constant / trusted-set aren't suitable for this specific scenario). With the hook active, the toast successfully appears on the new video, but the click rule does not click it.

www.bilibili.com##+js(trusted-set, Object.prototype.expStore.isLoginTrialToastExpActive, true) // might break some features.
www.bilibili.com##+js(trusted-set, Object.prototype.isLoginTrialToastExpActive, true) // not work for this case.
www.bilibili.com##+js(trusted-set, Object.prototype.isViewToday, true) // not work for this case.

Questions:

  1. Is it possible to update trusted-click-element so it re-triggers after SPA navigations?
  2. If not, would you ever consider adding a set-desc trusted-set-desc scriptlet for scenarios requiring Object.defineProperty, Object.defineProperties hooks?
example.com##+js(set-desc, ownerMatch, propMatch, descMatch(get/set/value), constant(replace the get/set/value))
example.com##+js(trusted-set-desc, ownerMatch, propMatch, descMatch(get/set/value), constant(replace the get/set/value))
www.bilibili.com##+js(trusted-set-desc, , isViewToday, isLoginTrialToastExpActive, trueFunc)

Feel free to close this if it's out of scope or if there are no plans for it. Thanks for everything you do!

A specific URL where the issue occurs.

https://www.bilibili.com/video/BV1CDYg69EGL

Steps to Reproduce

(Note: To reproduce this, you must use a userscript to hook Object.defineProperty, Object.defineProperties so the trial toast is forced to appear on subsequent videos. Without the hook, the toast will not show for the new video at all, so the click failure cannot be observed).

  1. Open the URL in a private window (unlogged).
  2. Add this rule:
www.bilibili.com##+js(trusted-click-element, '.bpx-player-toast-wrap .bpx-player-toast-confirm-login, .bpx-player-control-wrap .bpx-player-ctrl-quality-menu-wrap .bpx-player-ctrl-quality-menu-item[data-value="80"]', !cookie:/^DedeUserID=/)
  1. Inject a script (e.g., via Violentmonkey) to hook Object.defineProperty, Object.defineProperties so the trial mode is forced on for every video.
  2. Load the page. Notice the rule successfully auto-clicks the trial toast.
  3. Click a related video on the right sidebar (triggers SPA navigation).
  4. The trial toast successfully appears for the new video (due to the hook).
  5. Notice the trusted-click-element rule does not click the toast this time.

Expected behavior

trusted-click-element should re-arm/trigger again for dynamically loaded elements after SPA navigation.

Actual behavior

trusted-click-element only fires once per page load.

Configuration

Details
uBlock Origin: 1.74.1b7
Firefox: 158
filterset (summary):
 network: 0
 cosmetic: 0
 scriptlet: 0
 html: 0
listset (total-discarded, last-updated):
 removed:
  ublock-filters: null
  ublock-badware: null
  ublock-privacy: null
  ublock-unbreak: null
  ublock-quick-fixes: null
  easylist: null
  easyprivacy: null
  urlhaus-1: null
  plowe-0: null
 default:
  user-filters: 0-0, never
filterset (user): [empty]
switchRuleset:
 added: [array of 6 redacted]
hostRuleset:
 added: [array of 643 redacted]
userSettings:
 advancedUserEnabled: true
 cloudStorageEnabled: true
 cnameUncloakEnabled: false
 userFiltersTrusted: true
hiddenSettings:
 allowGenericProceduralFilters: true
 extensionUpdateForceReload: true
 filterAuthorMode: true
 trustedListPrefixes: ublock- user- https://raw.githubusercontent.com/JoviDong/
 updateAssetBypassBrowserCache: true
supportStats:
 allReadyAfter: 187 ms
 maxAssetCacheWait: 16 ms
 cacheBackend: indexedDB

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions