A group to collaborate on ways to get user scripts to work with other non-GM-enabled browsers that support user scripting capabilities.
What browser you prefer is irrelevant. Dividing ourselves into separate browser camps just dilutes our message. We're here because we love to change the way we view and use the web through user scripts.
This group is a place to:
- list scripts that are cross-browser compatible
- get help with making your own scripts cross-browser compatible
- request scripts on Userscripts.org to be made cross-browser compatible
- learn how to install scripts in other browsers besides Firefox
Cross-browser Guidelines
Assuming your script doesn't need to store and retrieve data across multiple domains or make XHR requests and post across multiple domains(GM_xmlhttpRequest ), there is really no reason why you have to pigeon-hole your script to only being Greasemonkey Compatible. More and more browsers are adding support for user scripts and most of the time it isn't that much of an effort to make sure your script can appeal to a larger audience. Here are some basics things to avoid:
- EX4: if you don't know what that is then good because only Firefox supports it. The benefit of having muti-line variables is not worth the expense of making other browser choke on your code.
- GM_addStyle: it is so easy to include this code in your script:
if (typeof GM_addStyle == 'undefined') var GM_addStyle = function(css) { var head = document.getElementsByTagName('head')[0], style = document.createElement('style'); if (!head) return; style.type = 'text/css'; style.textContent = css; head.appendChild(style); } - unsafeWindow: yes you do need this to access page variables, but if you only need to redefine functions in the page you add your code with this:
function addScript(js) { var body = document.body, script = document.createElement('script'); if (!body) return; script.type = 'text/javascript'; script.textContent = js; body.appendChild(script); }otherwise if you need to get data back from the page you can use this code:if (typeof unsafeWindow == "undefined") var unsafeWindow=window;This unfortunately doesn't work in Chrome so fuck 'em. - GM_log: A great function for testing your scripts, it outputs to the error console
if (typeof GM_log == "undefined") GM_log = (window.opera) ? opera.postError : console.log; - GM_registerMenuCommand: no simple alternative so either instead place a link on the page in place of it or save it for GM only features.
- GM_openInTab: it's nice, but there no sense in breaking your script, so use this to replace it:
if (typeof GM_openInTab == "undefined") GM_openInTab = window.open;
- @require: try to avoid it, but understand that sometimes it is needed.
Recently joined members
- untitaker 10 hours ago