jtackaberry / nosquint

NoSquint is a Firefox add-on that allows you to adjust the text-only and full-page zoom levels as well as color settings both globally (for all sites) and per site.
https://urandom.ca/nosquint/
The Unlicense
40 stars 16 forks source link

Nosquint issue on youtube. #159

Open ghost opened 10 years ago

ghost commented 10 years ago

Hello

I have a problem with nosquint, when I go on youtube.com and type whatever I want to search in search bar, nosquint became disabled until I reload page.

CrlyWrly commented 10 years ago

@stapi23 Same problem - but I hadn't realised that reloading the page would trigger Nosquint! Thanks for the tip - it would be good to have it fixed but it helps to know that in the meantime.

I do hope Jason is able to continue maintaining Nosquint - accessing the internet would be so difficult without it!

Genrei commented 9 years ago

Also have this problem, is there any way to fix this?

Jonathan-92 commented 9 years ago

Same here. Didn't know about the refresh trick either, thanks :P And it's the same with Facebook when an embedded youtube video is played

ManUnix commented 9 years ago

Hi,

since this bug annoyed me for a too long time, I've debugged it and found the code where it originates from:

File (in the xpi): chrome/nosquint/content/lib.js In the repository: https://raw.githubusercontent.com/jtackaberry/nosquint/master/src/content/lib.js

/* In the common case, document.URL == browser.currentURI.spec, so we test
 * this simple equality first before resorting to the probably unnecessary
 * regexp call.
 */
if (document.URL !=  browser.currentURI.spec &&
    document.URL.replace(/#.*$/, '') != browser.currentURI.spec.replace(/#.*$/, ''))
    /* Kludge: doc.URL doesn't match browser currentURI during host lookup failure,
     * SSL cert errors, or other scenarios that result in an internal page being
     * displayed that we consider chrome.
     */
    return true;

At the time when NoSquint doesn't set the zoom properly, the variables look like this:

So, what happens is, the above condition returns "true". That prevents NoSquint from applying your defined zoom because the function (which returned "true" in that case) is "isChrome()". That method is used to check whether the visited URL is a Firefox-internal page (for example "about:config") or a browser-internal error page for which no zoom should be applied.

To resolve the issue I'd remove the above code and replace

// A couple other common cases.
if (document.contentType == 'text/html' || document.contentType == 'application/xhtml+xml')
    return false;
if (document.URL == undefined || document.URL.substr(0, 6) == 'about:')
    return true;

with

// A couple other common cases.
if (document.URL == undefined || document.URL.substr(0, 6) == 'about:') {
    return true;
if (document.contentType == 'text/html' || document.contentType == 'application/xhtml+xml')
    return false;

That ensures that NoSquint still doesn't apply the zoom to Firefox-internal pages but can handle Youtube's (and other's) URL mismatch properly.

After that, the following two lines are obsolete:

if (document.URL == undefined)
    return true;
jtackaberry commented 9 years ago

Thanks for doing the leg work on this, @ManUnix. Clearly the original premise in that code isn't true (or is no longer true, anyway). I'll test this new logic out.