Skip to content

Instantly share code, notes, and snippets.

@cfenzo
Created December 4, 2012 08:08
Show Gist options
  • Save cfenzo/4201738 to your computer and use it in GitHub Desktop.
Save cfenzo/4201738 to your computer and use it in GitHub Desktop.
A small userscript to add a "add tab to page" button to an apps summary-page
// ==UserScript==
// @name Add facebook app to page -button
// @namespace http://webfreak.no/
// @version 0.1
// @description Adds a button to the summary-screen for facebook-apps, and adds a button in the header for adding the tab to a page (if a tab is specified).
// @match https://developers.facebook.com/apps/*/summary/
// @copyright 2012+, enzo @ webfreak.no
// ==/UserScript==
(function(){
var ifstatement = "if(document.getElementById('secure_page_tab_url') && document.querySelectorAll('#developerAppHeader a')){";
var part1 = "'https://www.facebook.com/dialog/pagetab?app_id='+document.querySelectorAll('#developerAppHeader a')[0]['href'].split('/').pop()+'&display=popup&next='+ encodeURIComponent(document.getElementById('secure_page_tab_url').value),'Add tab to page','status = 1, height = 250, width = 350, resizable = 0'";
var button = '<label class="uiButton" style="float:right;"><input type="button" onclick="javascript: '+ifstatement+'window.open('+part1+')};" value="Add tab to page" /></label>';
document.getElementById('developerAppHeader').innerHTML = document.getElementById('developerAppHeader').innerHTML + button;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment