Enable chrome extension when a tab is opened matching a url - javascript

I am pretty new to Chrome extensions and Javascript so any help will be great. Currently I have an extension that takes the currently playing song on tunein.com and populates links to search for the song on Spotify, YouTube, Google Play Music and Google. GitHub link here for reference. I'm currently enabling the extension when you are actively on the tab where tunein.com is playing but I would like to be able to make it work even when that tab is in the background.
I also worry if this will break my current implementation where I am traversing the DOM to get the name of the song and artwork. A lot of the tutorials I was using to develop this have mainly focused on the activeTab. From my cursory research I would set a flag in localStorage and do a check when a new tab is opened but I'm not sure how to access the DOM of a tab in the background or if that is even possible.
Any help would be greatly appreciated!

Related

Force Open External Browsers instead of any in-app browser [HTML/Javascript]

I've already researched and found a lot on this topic, but there's an idea that I still couldn't find and wanted to see if it's possible.
A bit of a background, I'm not a back-end developer and I'm not as well versed in it. But I have written a small website using HTML, CSS & Javascript (jQuery).
In-app browser is a problem for me since I am using localStorage to store some information for the user, and being its in-app then the user will lose all those details once they leave instagram, for example.
I've come upon a few results, and some here on stackoverflow, but some answers did not work (link 1, link 2) and most answers said that this is not possible anyway.
So I was wondering (and I'd take this as a learning experience) about the following use case:
Let's take Instagram as the example here. If we set in our bio the link to youtube let's say, the youtube website will display at the top "Open in App" button, which in that way can then open the native youtube app and the user can continue normally. In that sense, isn't it possible to let's say, to create a button like "Open in Safari", and once the user opens my website they will be able to tap it and it would open the safari app with its appropriate link? Or is this not possible also since it should be coded from Safari's end?
A URL Scheme is what you need. for example:
Google Chrome:
googlechrome://domain
Safari:
safari-https://domain
Firefox:
firefox://open-url?url=domain
Opera:
opera-https://domain
X Web:
x-web-search://search+term

How to bypass Chrome disabling autoplay of video's in background tabs

my friends and I are making a website that acts like a radio station called Musare with playlists of YouTube videos that play after each other.
Recently Chrome introduced a new 'feature' that automatically disables autoplaying of videos in background tabs with no option to turn this off. This breaks our site because users don't want to keep going back to the site to start a song. This also broke other big sites, like YouTube playlists, Facebook chat notification sound and a lot of music sharing sites.
By now, a lot of sites have found solutions to bypass this, like dubtrack.fm, YouTube, Facebook and probably some other sites as well.
There is someone working on making an option for it at https://codereview.chromium.org/1414853003/, but that might take weeks or even months for it to be in the main Google Chrome.
If anyone knows how to bypass this, please let me know.
Thanks in advance :)
Already tried:
Starting another video before the current one ends - no success
Messing around with the Player Variables - no success
Other things probably - no success
Extra notes:
We are using the YouTube API. We use YT.Player and the youtubePlayer.loadVideoById(id)
SoundCloud streaming works fine with SC.Stream.
The source code for our project is at https://github.com/Musare/Musare
So I have found out how to bypass it finally, after many hours of trying and researching.
If you just initialize the iframe player of YouTube by using the YT.Player constructor, you can then just use the player variable and use yourPlayerVariable.loadVideoById(id).
You have to first go to the tab for it to start, but after that it will be able to load and play video's without you having to go back to the tab. If you remove and re-add the iframe, you will have to go back for it to start again.

"Noisy Tabs" in Google Chrome- Detecting if sound is playing

Google Chrome recently introduced the feature that allows users to tell what tab is making that "Noisy sound". What i'm interested in finding out is if this new feature allows chrome extensions to detect if a tab is making a sound.
There is no documentation of any similar feature on the chrome.tabs developer page. Is there a way that you would be able to detect if a sound is playing (Without taking a "guess" based off of the content of the page i.e if the page contains mp3 or video content)
necromancer here ...
It's now possible in Chrome 45 :
https://developer.chrome.com/extensions/tabs
boolean (optional) audible
Since Chrome 45. Warning: this is the current Beta channel. Learn more.
Whether the tab has produced sound over the past couple of seconds

Can a browser plugin lazy load images?

Before spending time learning the plug-in architecture I was hoping someone could let me know if what I want to do is even possible and possibly offer some guidance.
I've never written a browser plug-in before but I have am an experience programmer who is pretty good with JavaScript which I understand is what at least chrome extensions use. I have written a small app for the Samsung TV platform.
One webpage I visit on a regular basis loads a lot of images on a page and I don't want to wait until the developers improve the site. I'm hoping I could build a Chrome or Firefox extension that can identify when I'm viewing a page on that domain and prevent images from loading until some user interaction.
I was hoping when I changed the content settings in Chrome to not show images that there would be some way to individually load images (maybe a "show this image" in context menu, but there wasn't. Nothing came up when trying to search for an existing extension either.
Is it possible to have an extension manipulate the DOM to prevent the page from making requests for the images? I'm thinking replacing the src attribute with a local image as a placeholder, then changing it back depending on user interaction.

Embeded youtube view gets counted with Javascript API but not with IFrame

*Situation is -*I have to design a webpage that works on both desktop and on mobile devices, that plays an embeded youtube video (not autostarted) which then i can use interact with the video to get the play state etc (using this to count the total time watched, excluding pause/buffer/stop time)
I've managed to build the website using both the IFrame API and Javascript API from Youtube.
*However the problem is-*With Javascript API, the player on the desktop works and the view gets counted too but it doesnt work when i view it on a mobile device. The place where it should show the video (the div tag) doesnt react.
With the IFrame API, everything works in terms of functionality but when i press play on the video, the views do not get counted - accessed from both desktop and mobile. I've tested the viewcount several times, with different IP etc but while javascript API web gets counted instantly, IFrame API web is still not getting counted..
Does anyone have any suggestion to this problem?
Just to remind you, the crucial aspect of the webpage that i need are:
Embeded Youtube player
Being able to interact with the player (e.g. getState() or getDuration())
Website fully functional with mobile access
Valid view count
Thank you all in advance!! :)
Are you sure that the views are really being counted via the javascript api? I have always read that view counts only are considered valid when initiated using the actual YT play button. Meaning you can't initiate play via any API call and have the view count.
Here is a a somewhat dated blog post from Google/Youtube team explaining - https://groups.google.com/forum/#!msg/youtube-api-gdata/7SsbvOJMWL0/rBCBqnFaxRgJ
I'm trying to find something that says this has changed but so far no luck.
** EDIT **
So I went back to the iFrame and Javascript API pages and if you do a search for 'view count' the first piece of content you'll find is a line stating --
"Note: A playback only counts toward a video's official view count if it is initiated via a native play button in the player."
Re-reading your post I'm not sure if you are using the API's to play the video or just to get data from its current state. If you are using it to actually initiate play then the view counts are not actually being counted. If you are seeing something different I'd love to see and learn from it.

Categories

Resources