Skip to content

Commit

Permalink
Only run features on appropriate pages
Browse files Browse the repository at this point in the history
Adds relevant `exclude` and `match` properties to sox.features.info.json
for all features, so features only run on pages they were designed to
run on.

Part of #391.
  • Loading branch information
shu8 committed Jun 2, 2019
1 parent 86d9713 commit 4f5c5eb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
52 changes: 26 additions & 26 deletions sox.features.info.json
Expand Up @@ -35,7 +35,7 @@
"extended_description": "Highlight the username of a commenter if they have posted an answer on that page.",
"meta": "http://meta.stackexchange.com/questions/19574/highlight-comments-from-answer-author-in-addition-to-question-author",
"match": "*://*/questions*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["major_ui", "key_feature", "power_user"]
}, {
"name": "displayName",
Expand All @@ -48,22 +48,22 @@
"desc": "Make bounty box draggable",
"meta": "http://meta.stackexchange.com/questions/170125/make-bounty-custom-message-dialog-box-draggable",
"match": "*://*/questions*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}, {
"name": "highlightQuestions",
"desc": "Change highlighting for questions with favourite tags",
"extended_description": "Changes the favourite tag question highlighting to be a more subtle, coloured left-border",
"meta": "http://meta.stackexchange.com/questions/238591/should-favorite-tag-highlighting-in-question-lists-be-changed",
"match": "",
"exclude": "*://chat.*.com/*",
"exclude": "*://chat.*.com/*,*://*/questions/*",
"feature_packs": ["major_ui", "key_feature", "power_user"]
}, {
"name": "isQuestionHot",
"desc": "Add a label on questions which are hot-network questions",
"extended_description": "If the question you are currently viewing is HOT, a flame icon is added next to the title",
"meta": "http://meta.stackexchange.com/questions/245390/let-mods-and-10k-know-when-questions-go-hot",
"match": "*://*/questions/*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}, {
"name": "localTimestamps",
"desc": "Convert timestamps to your local time",
Expand All @@ -81,7 +81,7 @@
"desc": "Add the SO logo after employee names to make them stand out",
"meta": "http://meta.stackexchange.com/questions/246678/should-se-staff-have-a-special-character-in-their-user-name",
"match": "",
"exclude": "*://chat.*.com/*,SE1.0",
"exclude": "*://chat.*.com/*,SE1.0,*://*/questions/ask",
"feature_packs": ["major_ui", "key_feature", "power_user"],
"usesApi": true
}, {
Expand Down Expand Up @@ -132,7 +132,7 @@
"desc": "Improve answer visibility by listing top answers",
"meta": "",
"match": "*://*/questions*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}, {
"name": "unspoil",
"desc": "Add a link to the bottom of a post to reveal all spoilers in a post",
Expand All @@ -144,7 +144,7 @@
"desc": "Add timeline and revision links to the bottom of each post for quick access to them",
"meta": "",
"match": "*://*/questions*,*://*/review*",
"exclude": "",
"exclude": "*://*/questions/ask",
"feature_packs": ["power_user"]
}, {
"name": "showTagWikiLinkOnTagPopup",
Expand All @@ -158,7 +158,7 @@
"desc": "Hide the 'welcome back...don't forget to vote' message when visiting a site after a while",
"meta": "",
"match": "*://*/questions*",
"exclude": ""
"exclude": "*://*/questions/ask"
}, {
"name": "hideHowToAskWhenZoomed",
"desc": "Hide the 'How to ask/format/tag' yellow boxes that appear when asking a question whilst zoomed in",
Expand All @@ -172,21 +172,21 @@
"extended_description": "This feature will automatically detect comments with links to imgur and will display them inline",
"meta": "",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["major_ui, key_feature", "power_user"]
}, {
"name": "commentReplies",
"desc": "Add reply links to comments for quick replying (without having to type someone's username)",
"meta": "http://meta.stackexchange.com/questions/74778/add-reply-link-to-comment-that-pre-populates-comment-box-with-username",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"]
}, {
"name": "commentShortcuts",
"desc": "Use Ctrl+I,B,K (to italicise, bolden and add code backticks) in comments",
"meta": "http://meta.stackexchange.com/questions/14756/formatting-keyboard-shortcuts-for-comments",
"match": "*://*/questions*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}, {
"name": "confirmNavigateAway",
"desc": "Add a confirmation dialog when navigating away on pages whilst still typing a comment",
Expand Down Expand Up @@ -225,14 +225,14 @@
"desc": "Only show the comment actions (flag/upvote) when hovering over a comment",
"meta": "https://meta.stackexchange.com/q/312794",
"match": "*://*/questions*,*://*/review*",
"exclude": ""
"exclude": "*://*/questions/ask"
}],
"Editing": [{
"name": "addSBSBtn",
"desc": "Add a button to the editor toolbar to start side-by-side editing",
"extended_description": "An 'SBS' button is added to the right of the markdown editor toolbar. Clicking it will make the markdown and the preview appear side-by-side",
"meta": "http://meta.stackexchange.com/questions/253112/the-discourse-layout-for-side-by-side-markdown-preview",
"match": "",
"match": "*://*/questions/*",
"exclude": "*://chat.*.com/*,SE1.0",
"settings": [{
"id": "sbsByDefault",
Expand All @@ -245,16 +245,16 @@
"desc": "Pre-defined edit comment options (checkboxes)",
"extended_description": "Adds checkboxes to add canned messages for edit revisions when editing. You can make *your own* canned responses by clicking the 'Edit Reasons' button that is added to the Help dropdown menu in the topbar",
"meta": "http://meta.stackexchange.com/questions/190461/improve-the-editing-flow-with-predefined-options-for-edit-summary",
"match": "",
"exclude": "*://chat.*.com/*,SE1.0",
"match": "*://*/questions/*",
"exclude": "*://chat.*.com/*,SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"]
}, {
"name": "editReasonTooltip",
"desc": "Add a tooltip to posts showing the last revision's comment",
"extended_description": "When a post is edited, the editor is displayed underneath the post. This feature will show what the last revision's comment was as a tooltip when you hover over 'edited' underneath a post in 'edited [date] at [time]'",
"meta": "http://meta.stackexchange.com/questions/2315/show-reason-for-edit-without-clicking-through-to-diff",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"]
}, {
"name": "findAndReplace",
Expand Down Expand Up @@ -282,13 +282,13 @@
"extended_description": "Enables the inline editor on all sites, even if you don't have 2k rep there yet. Note: this feature may not work on Firefox.",
"meta": "",
"match": "*://*/questions*",
"exclude": ""
"exclude": "*://*/questions/ask"
}],
"Flags": [{
"name": "flagOutcomeTime",
"desc": "Show the flag outcome time when viewing your Flag History",
"meta": "",
"match": "",
"match": "*://*/users/*",
"exclude": "*://chat.*.com/*,SE1.0"
}, {
"name": "flagPercentages",
Expand Down Expand Up @@ -334,7 +334,7 @@
"desc": "Hide the 'Love this site?' module",
"meta": "",
"match": "",
"exclude": "*://chat.*.com/*"
"exclude": "*://chat.*.com/*,*://*/review*"
}, {
"name": "linkedToFrom",
"desc": "Add an arrow to linked posts in the sidebar to show whether they are linked to or linked from",
Expand Down Expand Up @@ -395,14 +395,14 @@
"desc": "Make vote buttons next to posts sticky whilst scrolling on that post",
"meta": "http://meta.stackexchange.com/a/35047/260841",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["major_ui, key_feature", "power_user"]
}, {
"name": "disableVoteButtons",
"desc": "Disable vote buttons on your own posts and deleted posts, which you cannot vote on",
"meta": "",
"match": "*://*/questions*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}],
"Extras": [{
"name": "linkedPostsInline",
Expand All @@ -424,7 +424,7 @@
"desc": "Show when the post's author was last seen and whether they are registered",
"meta": "",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"],
"usesApi": true
}, {
Expand All @@ -433,21 +433,21 @@
"extended_description": "When you click 'share' under a post, this displays a referral link, which incorporates your user ID. This option strips your user ID from the displayed link, preventing inadvertent privacy leaks when disseminating the link via copy-paste. The social-media sharing buttons are unaffected, since the lack of privacy is obvious.",
"meta": "https://meta.stackexchange.com/questions/74274/privacy-leak-in-permalink",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0",
"exclude": "SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"]
}, {
"name": "shareLinksMarkdown",
"desc": "Change 'share' link to format of [post-name](url)",
"extended_description": "When you click 'share' under a post, this will convert the URL given to a markdown-friendly version, with the post name as the link text. This feature also automatically copies the converted string to your clipboard",
"meta": "http://meta.stackexchange.com/questions/126544/add-a-second-share-button-to-posts-with-comment-ready-links",
"match": "*://*/questions*,*://*/review*",
"exclude": "SE1.0"
"exclude": "SE1.0,*://*/questions/ask"
}, {
"name": "sortByBountyAmount",
"desc": "Add an option to filter bounties by their amount",
"meta": "http://meta.stackexchange.com/questions/7753/please-give-us-the-ability-to-sort-featured-tab-by-bounty-amount",
"match": "",
"exclude": "*://*/users/*,*://chat.*.com/*,SE1.0"
"exclude": "*://*/users/*,*://chat.*.com/*,SE1.0,*://*/questions/*,*://*/review*"
}, {
"name": "warnNotLoggedIn",
"desc": "Warn you when you are not logged in",
Expand Down Expand Up @@ -531,7 +531,7 @@
"extended_description": "Allows you to create your own magic links ('[text]' auto-converts to a link of your choice). Links can use the placeholders $BASEURL, $METABASEURL, $QUESTIONID, and $ANSWERID which are auto-replaced with the respective data. You can set the reasons by clicking the 'Magic Links' button added to the 'Help' dropdown at the top-right of the page. See https://stackapps.com/q/6650 for more details.",
"meta": "",
"match": "",
"exclude": "*://chat.*.com/*,SE1.0",
"exclude": "*://chat.*.com/*,SE1.0,*://*/questions/ask",
"feature_packs": ["power_user"]
}]
}
Expand Down
2 changes: 2 additions & 0 deletions sox.features.js
Expand Up @@ -1829,6 +1829,7 @@
};
});
const $editor = $('.review-more-instructions ul:eq(1) li');
if (!$editor.length) return;
const editorName = $editor.find('a').text();
const editorLink = $editor.find('a').attr('href');
const editorApproved = $editor.clone().find('a').remove().end().text().match(/([0-9]+)/g)[0];
Expand Down Expand Up @@ -2441,6 +2442,7 @@
if (document.getElementById(PROCESSED_ID)) return;

const $anchor = $('.summary h2 a');
if (!$anchor.length) return;
const postId = sox.helpers.getIDFromAnchor($anchor[0]);
const QUESTION_STATE_FILTER = '!-MOiNm40B3fle5H6oLVI3nx6UQo(vNstn';

Expand Down
2 changes: 1 addition & 1 deletion sox.user.js
Expand Up @@ -3,7 +3,7 @@
// @namespace https://github.com/soscripted/sox
// @homepage https://github.com/soscripted/sox
// @homepageURL https://github.com/soscripted/sox
// @version 2.4.33 DEV
// @version 2.4.34 DEV
// @description Extra optional features for Stack Overflow and Stack Exchange sites
// @contributor ᴉʞuǝ (https://stackoverflow.com/users/1454538/, https://github.com/mezmi)
// @contributor ᔕᖺᘎᕊ (https://stackexchange.com/users/4337810/, https://github.com/shu8)
Expand Down

0 comments on commit 4f5c5eb

Please sign in to comment.