legierski / bookmarklet-to-extension

Bookmarklet to Chrome Extension
126 stars 29 forks source link

Bookmarklet works, Extension does not. #3

Open daryllabar opened 8 years ago

daryllabar commented 8 years ago

Here is my bookmarklet code:

javascript:var form=$("iframe").filter(function(){return $(this).css("visibility")=="visible"})[0].contentWindow;try{form.Mscrm.InlineEditDataService.get_dataService().validateAndFireSaveEvents=function(){return new Mscrm.SaveResponse(5,"")}}catch(e){}var attrs=form.Xrm.Page.data.entity.attributes.get();for(var i in attrs){attrs[i].setRequiredLevel("none")}var contrs=form.Xrm.Page.ui.controls.get();for(var i in contrs){try{contrs[i].setVisible(true);contrs[i].setDisabled(false);contrs[i].clearNotification()}catch(e){}}var tabs=form.Xrm.Page.ui.tabs.get();for(var i in tabs){tabs[i].setVisible(true);tabs[i].setDisplayState("expanded");var sects=tabs[i].sections.get();for(var i in sects){sects[i].setVisible(true)}}

When executing as a Bookmarklet, the $("iframe") returns a jQuery object, and everything runs as expected. When running as an extension, it returns the iFrame itself, not the jQuery object, resulting in the filter function not being defined, and throwing an exception.

Any ideas as to how to resolve the issue?

legierski commented 8 years ago

My guess would be the jQuery that runs on the page is not accessible from within the extension.

daryllabar commented 8 years ago

Any ideas of how to resolve that?