facebook.js
options.htmlCode:var port = chrome.extension.connect(); var default_css = "#home_filter_list\n{width: 100% !important; display: block !important; margin: 0px 0px 15px;}\n\n#home_stream\n{width:auto !important;}"; function filterPlacement(feedPosition) { var filterPosition = port.getElementById(feedPosition).value; switch(filterPosition) { case "top": $("#home_filter_list").insertBefore("#pagelet_reqbox"); var css = default_css; break; case "bottom": $("#home_filter_list").insertAfter("#pagelet_syndicationbox"); var css = default_css; break; case "original": var css = "#home_filter_list\n{display: block !important;}"; break; default: break; } }; // change style of facebook function styleChanges() { if (typeof GM_addStyle != "undefined") { GM_addStyle(css); } else if (typeof PRO_addStyle != "undefined") { PRO_addStyle(css); } else if (typeof addStyle != "undefined") { addStyle(css); } else { var heads = document.getElementsByTagName("head"); if (heads.length > 0) { var node = document.createElement("style"); node.type = "text/css"; node.appendChild(document.createTextNode(css)); heads[0].appendChild(node); } } }; filterPlacement("position"); styleChanges();
manifest.jsonCode:<html> <head> <title>Facebook Options</title> <style> </style> <script type="text/javascript"> // Saves options to localStorage. function save_options() { var select = document.getElementById("position"); var position = select.children[select.selectedIndex].value; localStorage["favorite_position"] = position; // Update status to let user know options were saved. var status = document.getElementById("status"); status.innerHTML = "Options Saved."; setTimeout(function() { status.innerHTML = ""; }, 750); } // Restores select box state to saved value from localStorage. function restore_options() { var favorite = localStorage["favorite_position"]; if (!favorite) { return; } var select = document.getElementById("position"); for (var i = 0; i < select.children.length; i++) { var child = select.children[i]; if (child.value == favorite) { child.selected = "true"; break; } } } </script> </head> <body onload="restore_options()"> <div id="position_options"> News Feed Position: <select id="position"> <option disabled="disabled">Left</option> <option value="original">Original</option> <option disabled="disabled">Right</option> <option value="top">Top</option> <option value="bottom" selected>Bottom</option> </select> </div> <br> <button onclick="save_options()">Save</button> </body> </html>
so far i can't see any errors...but i can't figure out why my options page has no effect on the rest of the code...Code:{ "content_scripts": [ { "exclude_globs": [ ], "include_globs": [ "http://facebook.com/*", "https://facebook.com/*", "http://*.facebook.com/*", "https://*.facebook.com/*", "http://facebook.com/*", "https://facebook.com/*/*", "http://*.facebook.com/*/*", "https://*.facebook.com/*/*" ], "js": [ "jquery-1.3.2.min.js", "facebook.js" ], "css": [ "facebook.css" ], "matches": [ "http://*/*", "https://*/*" ] } ], "description": "Removes all of the ads found on facebook and moves the news menu to the right side to save space", "name": "Facebook Cleanup", "options_page": "options.html", "icons": { "128": "images/facebook128.png", "16": "images/facebook16.png", "32": "images/facebook32.png", "48": "images/facebook48.png" }, "version": "1.3.0" }
I'm also wondering if it would be better to just use jQuery to get the value of the select tag...if so how would i use it


LinkBack URL
About LinkBacks



Reply With Quote