Coder Social home page Coder Social logo

Comments (11)

vnctdj avatar vnctdj commented on June 13, 2024 2

@rugk
Now that I think of it, I believe you're right that some logging should be enabled by default.
A message like "extension_name has enabled dark mode on this page" is a very valuable information to have as a web developer.

from website-dark-mode-switcher.

rugk avatar rugk commented on June 13, 2024

Why?

in the website you mean?

from website-dark-mode-switcher.

vnctdj avatar vnctdj commented on June 13, 2024

On any site I visit, for every page loaded, your add-on is writing to the browser console.
While this can be useful for debugging, the production version of your add-on should not expose this behavior.

from website-dark-mode-switcher.

rugk avatar rugk commented on June 13, 2024

Yep, that's a good point. I guess I could try to integrate my Logger module, which I can use to expose a "debug mode" setting in add-on settings. (used e.g. in the Offline QR Code Generator add-on).
Or I may just remove the debugging console logs… (at least the one not triggered by the website)

Would you be fine to still receive logs if the add-on actually does something on the site, such as injecting CSS to get everything black? (because that may be good to know for devs, so they know when this add-on e.g. breaks it)

from website-dark-mode-switcher.

vnctdj avatar vnctdj commented on June 13, 2024

Sorry for the late reply...

The "debug mode" (or "dev mode" ?) setting approach seems the best one to me.
It would be really nice to hide all console logs by default and still being able to enable them at will in add-on settings :)

from website-dark-mode-switcher.

Juraj-Masiar avatar Juraj-Masiar commented on June 13, 2024

I was just about to file the same issue :). Please don't print anything into console unless user enables some debugging.
I mean, imagine if every add-on you have installed would print something about what it's doing into the console... it's already pretty bad now when every web-page spams console with all kinds of stuff.
I'm trying to develop my content scripts on some "clean" pages, but add-ons can print even there.

Thank you in advance :)

from website-dark-mode-switcher.

rugk avatar rugk commented on June 13, 2024

Okay, that said, I think I am not going the "using a debug mode setting" way, because it's easier to implement just a reduction of the console messages.

E.g. if the add-on changes the style of your website, as a web-dev you may want to know that, because that influences how your website is displayed. And you may be confused, otherwise. (Also if the JS .matchMedia is faked. This can lead to bugs in your website, so it's good if you know where to report these. That's also why the URL is included in these console messages.)

from website-dark-mode-switcher.

Juraj-Masiar avatar Juraj-Masiar commented on June 13, 2024

For notifying user that your add-on did something, you can use badges.
Regarding debugging - you can still collect your logs in memory on each tab and when user click some "show logs" button, it can print them in the text area. Let's face it, how many of users will check the browser console to see why their page looks different :).

Please think about other fellow developers with their own problems that needs to dig into their own logs...

This is what my console now looks like on spotify when I play song:

13:57:48.575 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:57:48.567 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:57:48.595 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:57:48.596 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:57:48.764 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:57:48.758 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:57:48.791 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:57:48.792 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:57:49.163 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:57:49.154 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:57:49.187 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:57:49.187 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:57:55.016 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:57:55.009 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:57:55.031 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:57:55.031 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:58:09.472 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:58:09.464 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:58:09.486 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:58:09.487 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:58:31.180 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:58:31.168 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:58:31.198 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:58:31.200 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:59:02.121 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:59:02.106 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:59:02.138 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:59:02.138 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
13:59:32.535 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
13:59:32.528 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
13:59:32.551 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
13:59:32.552 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
14:00:14.903 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
14:00:14.897 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
14:00:14.916 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
14:00:14.917 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
14:01:06.309 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
14:01:06.298 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
14:01:06.321 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
14:01:06.322 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
14:01:47.665 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
14:01:47.655 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
14:01:47.680 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
14:01:47.680 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1
14:03:06.851 updated fakedColorStatus via background script injection to Symbol(prefers-color-scheme: dark) 662efc2b-5d2e-47ae-a469-a4b02c0c1847:4:29
14:03:06.841 Content Security Policy: Ignoring ‘x-frame-options’ because of ‘frame-ancestors’ directive.
14:03:06.872 set fakedColorStatus via content script to: Symbol(prefers-color-scheme: dark) common.js:16:13
14:03:06.873 Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”). 11 6DEjYFkNZh67HP7R9PSZvv:1:1

from website-dark-mode-switcher.

rugk avatar rugk commented on June 13, 2024

I don't want to notify users, but web-devs. (and they look into the console)

Uhm, that spotify example looks indeed excessive…

from website-dark-mode-switcher.

rugk avatar rugk commented on June 13, 2024

Okay, on sites where it does not do anything, it also does not log anything now…

It only logs some details, if it either injects CSS:
image

…or if it fakes the result of a JS checkMedia:
image

from website-dark-mode-switcher.

vnctdj avatar vnctdj commented on June 13, 2024

Nice!
And thanks for your fast reaction!

from website-dark-mode-switcher.

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.