Git Product home page Git Product logo

Comments (17)

An-dz avatar An-dz commented on July 27, 2024 1

The output is the same as your image and putting RefSelectorElement on the content script says it's not available, as I expected since content scripts can't access the page variables as it runs on a separate layer.

The same problem is happening on Firefox 78.

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Well, it seems that whenDefined isn't supported by your browser. Wait a moment, please, will fix it in a minute

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

I hope v4.3.2 is okay :)

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Note: in fact, custom elements are supported by the browser, but access to this functionality from content scripts is limited (as far as I can say by this issue)

from github-defreshed.

An-dz avatar An-dz commented on July 27, 2024

Still broken. But now there's no error on console, the loading just keeps spinning forever.

Checking the HTML it's normal crappy GitHub.

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Hm. It's really strange. I'm very sorry for the inconvenience, tomorrow I'll try to find a solution to this problem

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Hi! Didn't issue magically resolve itself while I was asleep? :D

Cannot reproduce the issue with Ungoogled Chromium 90.0.4430.212
image

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

If the problem persists, could you run this snippet on the repository page while it refuses to load, please?

const refSelector = document.querySelector("#branch-select-menu ref-selector");
console.log(refSelector.constructor);
await refSelector.index.fetchData();
console.log(refSelector.index.currentSearchResult);

Expected output:
image


If that snippet did work, could you check if content scripts in your browser have access to RefSelectorElement? This may help you:

// ==UserScript==
// @name         RefSelectorElement test
// @namespace    GitHub
// @version      0.1
// @match        https://github.com/*
// @run-at       document-idle
// @grant        none
// ==/UserScript==
(function() {
    "use strict";
    alert(window.RefSelectorElement ? "RefSelectorElement is accessible" : "RefSelectorElement is not accessible");
})();

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Content scripts can access and modify the page's DOM, just like normal page scripts can. They can also see any changes that were made to the DOM by page scripts.
However, content scripts get a "clean" view of the DOM. This means:

  • Content scripts cannot see JavaScript variables defined by page scripts.
  • If a page script redefines a built-in DOM property, the content script sees the original version of the property, not the redefined version.

Oh. Now I see. But I can't understand 2 things:

  1. Why is this even a thing? "Clean view of the DOM". Benefits of this are highly questionable
  2. Why it doesn't work for me (-> GitHub-Defreshed doesn't fail)? :D

from github-defreshed.

An-dz avatar An-dz commented on July 27, 2024

Why is this even a thing? "Clean view of the DOM". Benefits of this are highly questionable

Yes, not "write" to it seems reasonable so you don't need to worry about your variables breaking the page, but reading is pretty dumb.

Why it doesn't work for me (-> GitHub-Defreshed doesn't fail)? :D

At first I thought it could be you using Firefox, but it fails on mine and you have tested on Chromium.

But maybe it's how we have installed it. Are you using your XPI for Firefox? Or GreaseMonkey?

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Yes, not "write" to it seems reasonable so you don't need to worry about your variables breaking the page, but reading is pretty dumb

Completely agree! "This means that content scripts can rely on DOM properties behaving predictably, without worrying about its variables clashing with variables from the page script." Guys, "DOM properties behave predictably" when and only when they work same way they do when I'm browsing the website I made the script for...


But maybe it's how we have installed it. Are you using your XPI for Firefox? Or GreaseMonkey?

Ahaha, I forgot about GreaseMonkey :D I use TamperMonkey (yep, I know it's closed-source and so on, but I'm just used to it) and it seems it doesn't use Content Script API :D

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Well, I hope I've fixed the issue (+1 api call due to Content Script API restrictions -_-). Could you please check if this fix works for you, so I won't release broken version again? :D

You can grab build artifacts here

from github-defreshed.

An-dz avatar An-dz commented on July 27, 2024

Ahaha, I forgot about GreaseMonkey :D I use TamperMonkey (yep, I know it's closed-source and so on, but I'm just used to it) and it seems it doesn't use Content Script API :D

I don't use GreaseMonkey either, I used to use ViolentMonkey, but now I just create a pseudo-extension with a manifest and load from disk. For Firefox I use your XPI.

Well, I hope I've fixed the issue (+1 api call due to Content Script API restrictions --)_. Could you please check if this fix works for you, so I won't release broken version again? :D

It works now. 👍

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

I don't use GreaseMonkey either, I used to use ViolentMonkey, but now I just create a pseudo-extension with a manifest and load from disk. For Firefox I use your XPI

Isn't it a little bit tedious to do all of these manually? Why did you stop using ViolentMonkey?

It works now. 👍

Finally, haha :) I'll make few more changes (aka fixes, e.g., busy status is broken again) and then will release new version

Thank you so much for helping out with this one! I'm always too lazy to check that everything works outside of my usage scope (Firefox + userscript), so Chrome/Web Extension bugs are unnoticeable for me :D

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

v4.3.3 (which fixes the issue) was published :)

from github-defreshed.

An-dz avatar An-dz commented on July 27, 2024

Isn't it a little bit tedious to do all of these manually?

I just need to create the manifest once and then I just download the .user.js over the old one whenever you update it. GitHub alerts me when a release is made.

Why did you stop using ViolentMonkey?

It runs over every page even though my userscripts only run over some pages, Chromium will handle that faster and more secure for me. And the only userscript I use that I have not created is yours so I don't care about manually updating it.

from github-defreshed.

Kir-Antipov avatar Kir-Antipov commented on July 27, 2024

Oh, I see, that's reasonable :)

from github-defreshed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.