Google Chrome Extensions, Doesn't Respond to Bookmark Events - api

I am trying to utilize the Google Bookmarks API for Chrome Extensions (this is not the Google Bookmarks API as in http://www.google.com/bookmarks/, but rather Chrome Bookmarks API).
Anyway, I just tried a simple example which I have the background.html and the manifest.json listed below. However, I am not getting the alert dialog box. I am not getting this problem if I switch to using tab events. What am I doing wrong?
manifest.json
{
"name": "Google Bookmark Integration",
"version": "1.0",
"description": "Integrates Chrome bookmarks with Google Bookmarks.",
"icons": { "128": "images/bookmark.ico" },
"background_page": "background.html",
"permissions": [
"bookmarks",
"http://*.google.com/bookmarks/*"
]
}
background.html
<script>
chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
console.log("Bookmark Created");
});
</script>

JavaScript is dynamically typed and function definitions shouldn't have type names. Instead of (string id, BookmarkTreeNode bookmark), you need to write just (id, bookmark). Your background.html should be:
<script>
chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
alert("Dialog Box");
});
</script>
In addition, apparently Chrome has limited support for alert() inside extensions. (It worked for me in this particular case, but I've now found other cases where it doesn't.) Try console.log() instead. The Chrome Extensions documentation page on "debugging" has instructions for how to open the Developer Tools / JavaScript console for the background.html page, which you'll need to do.

To answer my own question, the problem here was that, not only do the permissions need to be set to "bookmarks" but they also need to be set to "tabs". Once I did this, the plug-in then recognized adding and removing bookmarks.
Very counterintuitive, but this is the solution.

If you want to see the console.log of the background script, then you need to go to chrome://extensions/ and click on Inspect views service worker and look for the message there.

Related

Missing a href tag in Safari, Edge and IE, but not Firefox, datatables?

I have a list of courses that links to instructor profiles, generated by PHP, and I'm using DataTables to sort and display. In Firefox, the <a href> tag around the instructor name is there, just as I coded it in the PHP. But when I view the same page in Microsoft Edge, IE or Safari, and I view the page source, there is no <a> tag there at all!
I can only guess that either
a) DataTables is stripping it for some reason? OR
b) there is some minor error in the DOM and the browser is stripping out the tag?
The URL is: http://ota.iewwritingteacher.com/courses - Each place where it says "Instructor:" followed by a name, is supposed to be a link.
The PHP code is straightforward:
<p>Instructor: <?php echo $event_meta['instructor']; ?></p>
Can anybody help me figure out what is going on?
In order to render a link from text, you need to do a little something different in Datatables.
$("#example").DataTable({
"data": final_data,
"columns": [
{
"data": "url",
"render": function ( data, type, full, meta ) {
return 'SOMETHING';
}
],
});
After a bunch of digging around, I realized that an OLD version of the page was being delivered by a caching plugin I did not install! Endurance Page Cache was installed as an mu-plugin by HostMonster, and thus, had static copies of an old version of the page (before I added the link to the code).
Why certain browsers delivered the page to me correctly, not from that cache, and others did not, I still do not know. But the problem is fixed now!

Modify External Browser Element via Vb.Net

Is that anyway to Modify firefox (or other browser) element with Watin/VB.Net after it open?
For example, I have a blank html page, then i open that page with Watin. Because its blank so no element loader. Then i want to add element to that page (form or link or image). Is that possible?
Or is it possible to done with memory editing? or maybe javascript?
so far the closest thing that i can find is this javascript
<button onclick="openTab()">Open</button>
<button onclick="closeTab()">Close</button>
<script>
var TAB;
function openTab() {
TAB = window.open("", "TAB");
TAB.document.write("<p>hi</p>")
}
function closeTab() {
TAB.close();
}
</script>
but its work change the elemnt of its own page, if use another URL its not work, and also its not vb. net XD
The following is functional code to modify a web page (any web page) using WatiN. You will be modifying the local copy you have locally, not the one on the server, of course. You can go as crazy as you want but you need to be more specific on what you want to achieve:
var browser = new IE();
browser.GoTo("about:blank");
browser.WaitForComplete();
browser.Eval(#"document.write('This is new text on the web page<br>')");
browser.Eval(#"var buttonnode= document.createElement('input');");
browser.Eval(#"buttonnode.setAttribute('type','button');");
browser.Eval(#"buttonnode.setAttribute('name','sal');");
browser.Eval(#"buttonnode.setAttribute('value','New Button');");
browser.Eval(#"document.body.appendChild(buttonnode);");

Datatables-editor : How to include plugins

The datatable editor (after the completed purchase of a developer license) avails a slew of additional plug-ins. One such example is "Bootstrap DateTimePicker". However, after following the guide on the page, I could not get the plugin to work.
I've included the external libraries of css and .js files. I've also added the necessary codes to declare the field type as "datetime".
"label": "Updated date:",
"name": "updated_date",
"type": "datetime",
Lastly, I included the additional Plug-in codes (.js) at the header with the rest of the .js script.
On testdrive, the form showed both date and time in text. However, the anticipated "pretty" bootstrap datetimepicker UI does not show.
Can anyone offer any pointers?
Assuming you have included all the correct .js and .css libraries as stated.
You probably just haven't initiated datepicker.
$(document).ready(function () {
... your datatables and editor configuration ...
$('.input-datepicker').datepicker();//<-- Initiates datepicker
//replace '.input-datepicker' with the class of your input element
});

videojs javascript plugins on firefox fail to load

I have identified a simple use-case where plugins don't work on firefox.
http://107.20.191.154/video-js/test.html
If you click this link, the "speed" plugin works on chrome and safari, but not for the latest version of firefox.
Any ideas why its not working? Perhaps I'm doing something wrong.
You have this:
$(function(){
var video = videojs("example_video_1", {
controls: true,
//more options
});
});
<video … data-setup='{"nativeControlsForTouch":false}'>…
Both having a data-setup attribute on the video element and the videojs() function would set up video.js. You shouldn't use both. One is "winning" on Firefox, he other on other browsers. You should use one method or the other, including all options you need there.

YouTube HTML5 API works fine, but displays 'origin' error in console [duplicate]

I have literally just copy & pasted the code from the YouTube developer page YouTube Player API Reference for iframe Embeds (from underneath the heading "Getting Started"). The only difference, is that I added an alert to fire when the state changed, because I thought I was doing something wrong within the onPlayerStateChange function.
You can see the jsFiddle at http://jsfiddle.net/jesMv/.
As stated, it's just an exact copy of the code from the YouTube developer page with the added
alert('State Changed')
as the first thing to fire in the onPlayerStateChange function.
Nothing is happening, however... No matter how I look at this and what I change, I simply can't get the onStateChange to do anything.
How can I fix this problem?
There was a temporary issue with the iFrame Player API (which was fixed in June 2013) that you can read about here: https://code.google.com/p/gdata-issues/issues/detail?id=4706
Jeff Posnick posted a temporary workaround here:
http://jsfiddle.net/jeffposnick/yhWsG/3/
As a temporary fix, you just need to add the event listener within the onReady event:
function onReady() {
player.addEventListener('onStateChange', function(e) {
console.log('State is:', e.data);
});
}
Make sure to remove the onStateChange event from the YT.PLAYER constructor (see the jsfiddle).
Also, as someone mentioned on the Google Code Issue Thread, you set an interval and poll the player for its current state instead of listening for the onStateChange event. Here is an example code snippet for doing that:
setInterval( function() {
var state = player.getPlayerState();
if ( playerState !== state ) {
onPlayerStateChange( {
data: state
});
}
}, 10);
Firefox and IE Issues
Other people have mentioned that Firefox will not instantiate the YouTube Player if it is placed in a container with the css property display: none. Internet Explorer will also not work with visibility: hidden. If you're finding this to be the issue, try positioning the container off the page with something like left: -150%.
Steve Meisner talks about this here: YouTube API does not appear to load in Firefox, IFrame gets loaded , but the onPlayerReady event never fires?
And another related SO question: YouTube iframe API - onReady and onStateChanged events not firing in IE9
Edit: I've edited this answer to be more thorough because people are still seeing this error after the original bug was fixed in 2013.
onStateChange does not work in any version of Internet Explorer or Edge. I assume it will begin working once Microsoft moves Edge over to being Chromium-based. But whether IE9, 11, or Edge, I cannot get this event to fire, even when it fires cleanly in Chrome, identical code.