-
Notifications
You must be signed in to change notification settings - Fork 14
Contributing
Thank you for considering to contribute to SOX!
Please follow the following steps when adding a new feature:
- Write a function that implements the feature
- Add it to the
featuresobject insox.features.js. It's name should be in camelCase - Add the feature to
sox.features.info.json. Please put it under the most fitting category (eg. underAppearance). The following fields should be used: -
name: required, the camelCase ID of the function you added to sox.features.js -
desc: required, a short description of the feature you're adding, which will be displayed in the control panel -
meta: a URL linking to a meta post if that is where you got the idea from/were trying to fix -
match: a string of comma-separated match patterns for URLs where the feature should run on -
exclude: a string of comma-separated match patterns for URLs where the feature should run on - Any CSS should be added to
sox.css, with a comment before it indicating which feature it is for. CSS rules should be prepended with the function ID (the camelCase name).
##Helper functions
SOX has various helper functions and getters you can use to get information:
-
sox.helpers.notify(message): log to the console, prepended withSOX: -
sox.site.id: get the current site ID -
sox.site.name: get the current site's name -
sox.site.type: get the current site's type (beta/main/meta/chat) -
sox.site.url: get the current page's hostname -
sox.site.href: get the current page's URL -
sox.site.apiParameter(siteName): get the site parameter for a givensiteName(retrieved withsox.site.name) -
sox.location.on(location): returnstrueif the current page's URL matches a givenlocationstring (internally usesindexOf) -
sox.location.onUserProfile: returnstrueif the user is currently on a user profile -
sox.location.onQuestion: returnstrueif the user is currently on a question page -
sox.location.match(matchPattern): returns true if the current page matches a given `matchPattern' -
sox.user.id: returns the current user's ID -
sox.user.rep: returns the current' user's reputation level -
sox.user.name: returns the current user's username -
sox.user.loggedIn: returnstrueif the user is logged in -
sox.user.hasPrivilege(privilege): returnstrueif the current user has enough reputation to have a certainprivilege(this is a string, and is the privilege name you see on the main privileges page)
##Testing locally
To test locally, simply create a userscript which //@require's the local version of your files. Here's a template that you can modify to work for your system:
// ==UserScript==
// @name Local SOX
// @match *://*.stackoverflow.com/*
// @match *://*.stackexchange.com/*
// @match *://*.superuser.com/*
// @match *://*.serverfault.com/*
// @match *://*.askubuntu.com/*
// @match *://*.stackapps.com/*
// @match *://*.mathoverflow.net/*
// @match *://github.com/soscripted/*
// @match *://soscripted.github.io/sox/*
// @exclude *://data.stackexchange.com/*
// @exclude *://api.stackexchange.com/*
// @require https://code.jquery.com/jquery-2.1.4.min.js
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
// @require https://api.stackexchange.com/js/2.0/all.js
// @require https://cdn.rawgit.com/timdown/rangyinputs/master/rangyinputs-jquery-src.js
// @require https://cdn.rawgit.com/jeresig/jquery.hotkeys/master/jquery.hotkeys.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.5.3/jquery.timeago.min.js
// @require file:///C:/User/Github/sox/sox.common.js
// @require file:///C:/User/Github/sox/sox.github.js
// @require file:///C:/User/Github/sox/sox.dialog.js
// @require file:///C:/User/Github/sox/sox.enhanced_editor.js
// @require file:///C:/User/Github/sox/sox.features.js
// @require file:///C:/User/Github/sox/sox.user.js
// @resource css file:///C:/User/Github/sox/sox.css
// @resource dialog file:///C:/User/Github/sox/sox.dialog.html
// @resource featuresJSON file:///C:/User/Github/sox/sox.features.info.json
// @resource common file:///C:/User/Github/sox/sox.common.info.json
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_getResourceText
// @grant GM_addStyle
// @grant GM_info
// ==/UserScript==
Make sure Tampermonkey/Greasemonkey has been allowed access to local file URLs!