How can I access a window variable from a chrome extension? [duplicate] - google-chrome

This question already has answers here:
Chrome extension - retrieving global variable from webpage
(5 answers)
Closed 8 years ago.
How can I access a window variable from a chrome extension?
For example, I want my extension to just log window.variable?
Is this at all possible?

You need to inject the script at runtime (as opposed to doing it from the content script).
From the injected script use either messages to pass it to the extension, or (easier) write what you need in a DOM element and read it from the DOM (but changing the dom might break the original page)
In the official samples shows how to inject the script by writting a tag.
I know this is a dup of the pointed gmail question but that question has a title that makes it hard to know its about injected scripts.

Related

URL Actions from URL only [duplicate]

This question already has answers here:
How do I add target="_blank" to a link within a specified div?
(7 answers)
Closed 6 years ago.
A quick question regarding URL target actions.
Is there a way to specify the target action of a URL within the URL?
Context: I can't edit the underlying code where links live in this particular instance, but I have full control over the links themselves. I'd like to be able to specify a link target (new tab, new window, same tab, etc) from a URL itself.
If that's possible, awesome!
If that's impossible, darn (and thank you for enlightening me).
There's no reliable way as far as I'm aware (it's a security concern). If you only have control of the URL because you're using some other system (you're not the admin), chances are the link is escaped for javascript. If it isn't:
Some link

How to let robots parse our custom html elements? [duplicate]

This question already has answers here:
How do search engines deal with AngularJS applications?
(15 answers)
Closed 6 years ago.
I have a website containing custom elements (i use angular 2), and google fails to parse them correctly :
It only sees
<my-app></my-app>
It seems that the value of this component is not retrieved at all by google robots.
Is there a best practice / workaround ?
Thanks for your help.
This has been asked a million times. Please refer to this question and this specific page by google.
Times have changed. Today, as long as you're not blocking Googlebot from crawling your JavaScript or CSS files, we are generally able to render and understand your web pages like modern browsers. To reflect this improvement, we recently updated our technical Webmaster Guidelines to recommend against disallowing Googlebot from crawling your site's CSS or JS files.
What you can do is getting the HTML of your rendered page and inserting it into the <my-app></my-app> tags without user information or the like.
This will get replaced anyway after Angular has booted up, this means you can even put something completely different in there.

What is <span>content</span> == $0 mean in html? [duplicate]

This question already has answers here:
What does ==$0 (double equals dollar zero) mean in Chrome Developer Tools?
(5 answers)
Closed 6 years ago.
I found a button in the google cloud front end that uses this syntax and I was just wondering what it is all about... Thanks for the input!
I love design patterns and have been getting more into web development lately so forgive me if this is a really basic question!
That's just the element inspector of your browser. It means in the browser's Javascript console, you can now type $0 and get an object that refers to your currently highlighted element. It's a handy shortcut for directly debugging DOM elements interactively.
It's not HTML, it's not even actually part of the web page, it's not specific to that button, it's not a design pattern.

IE9 fails to parse CSS file having more than ~ 4100 classes [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
is there any limit on css file size?
I have a generated CSS file coming from a third party application of around 60K lines with ~ 13K classes defined in that. I cannot change the generated CSS file by any means on the server (when it is generated from the third-party application) and the way it is injected in different HTML files on GET requests.
My target browser for the application is IE9 and it so happens that IE9 is failing to parse more than 4095 classes coming from one file and hence doesn't get the classes defined after that. Also, this number has been exact while debugging the generated file I have and another test file which I created (gist below) to verify this number.
Is there any workaround possible or am I missing any detail here ?
Illustration:
To give a quick way to reproduce this problem, here is a link to a gist that I have created. Just extract all the files in some folder and open ie9_test.html in IE9
https://gist.github.com/3941331
I couldn't find any service to show the output online where an IE9 environment is present. My IE9 build is 9.0.8112.16421
EDIT: The test files and my files work fine on chrome v22
Well one obvious workaround would be to break it up yourself into two or more files. You could then include both on the relvant pages. You would just have to write a simple css parser to identify where to cut up the file. And by simple I mean just find where classes start and begin so you know where to chop chop.

Chrome extension, how to Modify page content (add something) [duplicate]

This question already has answers here:
Modify HTML of loaded pages using chrome extensions
(2 answers)
Closed 6 years ago.
I'm new to Chrome extension development, my first project (to learn) is to create an extension that adds some html to another website's existing page.
I plan on creating a 'page' action which fires for a page with a certain URL...
Has anyone seen a tutorial like this, or do you know of an API for adding html to a page?
You can find some example at Google Sample Extension page, however your question seems better answered on this other question.
There are a number of sample extensions on the Chrome extension API site. There are a couple of browserAction examples that will be almost identical to using pageAction.