Wednesday, January 4, 2017

Using bookmarklets to instantly export webparts and other abilities

I've recently bumped into a blog post with mention of a tool that would convert a piece of JavaScript (that you would otherwise store in the server on in the browser through user scripts) to a bookmark!

This way, whenever you want to run a big chunk of code in your browser that would affect the currently opened website, you can simply push a button and off you go.

This is known as a "bookmarklet".

"A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser."

The concept is simple:

  1. Develop a script that would add some function to the existing website (but will be executed on demand instead)
  2. Go to the Bookmarkleter page to convert the script
  3. Drag-and-drop the bookmark (or create it yourself) with the new "link"


Examples of SharePoint bookmarklets:


My very own "SPDevTools"

This script will inject several buttons near the SharePoint ribbon with several functions, such as:

  • Display the file:// url for the current location (so that it can be quickly opened in explorer in non-IE browsers)
  • Display the site template ID
  • Refresh the page (no postback)
  • Get a link to the current page (handy in iframes)
  • Sign in as a different user (feature removed in SP2013)




Anatoly Mironov's Webpart Exporter

A long way has come since we used other methods to export webparts, such as:


  • Opening the URL: /_vti_bin/exportwp.aspx?pageurl=http://mysite/SitePages/Home.aspx&guidstring=WEBPARTIDGUID
  • manually inject AllowExport="true" in the html of the WebpartID element while in edit mode, which brings back the Export contextual menu option


This new method, bookmarlet supported of course, will actually find all the webparts in the current page and allow you to export every single one of them with a simple click.



Dan Saedén's Web Properties Updater

This other handy piece of code will display all the current Web's properties, and allow you to add, edit or remove any of them very easily.



Bonus
There is also a great Google Chrome plugin - "ChromeSPEditor" - that can manage UserCustomActions and Web Properties.


References

https://en.wikipedia.org/wiki/Bookmarklet

https://chuvash.eu/2015/10/21/export-any-web-part-using-a-bookmarklet/

http://www.rlvision.com/blog/edit-sharepoint-property-bags-with-sppropertybag-js-bookmarklet/

http://sharepoint.stackexchange.com/questions/199542/is-there-a-way-to-reference-jquery-inside-my-master-page-without-having-to-modif/199579

No comments:

Post a Comment