mirror of
https://github.com/wassname/Mostly-Harmless.git
synced 2026-07-16 01:20:12 +08:00
Added shameless plug (off by default)
This commit is contained in:
+2
-2
@@ -1,2 +1,2 @@
|
||||
# Ignore the files needed to deploy to the Chrome Web Store.
|
||||
deploy/**/*
|
||||
deploy/
|
||||
resources/
|
||||
@@ -10,4 +10,7 @@
|
||||
}
|
||||
textarea {
|
||||
font-family: Consolas, "Lucida Console", Monaco, monospace
|
||||
}
|
||||
}
|
||||
.setting.label.checkbox {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
+64
-50
@@ -3,6 +3,70 @@ this.manifest = {
|
||||
"name": "Mostly Harmless",
|
||||
"icon": "/pix/alien.png",
|
||||
"settings": [
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Fresh Content",
|
||||
"name": "freshCutoff",
|
||||
"type": "slider",
|
||||
"label": "",
|
||||
"max": 91,
|
||||
"min": 1,
|
||||
"step": 1,
|
||||
"display": true,
|
||||
"displayModifier": function(value) {
|
||||
if(value === 1)
|
||||
return "Show posts less than " + value.toString() + " day old";
|
||||
if(value <= 2 * 7)
|
||||
return "Show posts less than " + value.toString() + " days old";
|
||||
if(value > 2 * 7 && value < 7 * 7)
|
||||
return "Show posts less than " + Math.floor(value / 7).toString() + " weeks old";
|
||||
if(value >= 7 * 7 && value < 91)
|
||||
return "Show posts less than " + Math.ceil(value / 30).toString() + " months old";
|
||||
return "Show posts from all time";
|
||||
}
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Fresh Content",
|
||||
"name": "freshCutoffDescription",
|
||||
"type": "description",
|
||||
"text": "<p>This setting allows you to choose the oldest reddit posts you’d like to see. Anything posted before the value you’ve chosen will be indicated in the browser button's total, but will not be shown in the popup."
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Popup Width",
|
||||
"name": "popupWidth",
|
||||
"type": "slider",
|
||||
"label": "",
|
||||
"max": 784,
|
||||
"min": 480,
|
||||
"step": 1,
|
||||
"display": true,
|
||||
"displayModifier": function(value) {
|
||||
return value.toString() + "px";
|
||||
}
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Popup Width",
|
||||
"name": "popupWidthDescription",
|
||||
"type": "description",
|
||||
"text": "<p>This setting allows you to set the width of the browser action popup."
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Shameless Plug",
|
||||
"name": "shamelessPlug",
|
||||
"type": "checkbox",
|
||||
"label": "Show the shameless plug",
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Shameless Plug",
|
||||
"name": "shamelessPlugDescription",
|
||||
"type": "description",
|
||||
"text": "<p>When checked, this will add the following to each commment you post from within Mostly Harmless:</p><p><em>Posted from <a href='http://kerrick.github.com/Mostly-Harmless'>Mostly Harmless</a>, a Google Chrome extension for awesome redditors.<em></p>"
|
||||
},
|
||||
{
|
||||
"tab": "Performance",
|
||||
"group": "Cache Time",
|
||||
@@ -87,56 +151,6 @@ this.manifest = {
|
||||
"name": "excludedRegexDescription",
|
||||
"type": "description",
|
||||
"text": "<p>Put regular expressions, one per line, in the above text box. Please do not use the <code>\\n</code> character, because there should be no newlines in a URL. Any page that matches the listed regular expressions will <strong>not</strong> activate Mostly Harmless."
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Fresh Content",
|
||||
"name": "freshCutoff",
|
||||
"type": "slider",
|
||||
"label": "",
|
||||
"max": 91,
|
||||
"min": 1,
|
||||
"step": 1,
|
||||
"display": true,
|
||||
"displayModifier": function(value) {
|
||||
if(value === 1)
|
||||
return "Show posts less than " + value.toString() + " day old";
|
||||
if(value <= 2 * 7)
|
||||
return "Show posts less than " + value.toString() + " days old";
|
||||
if(value > 2 * 7 && value < 7 * 7)
|
||||
return "Show posts less than " + Math.floor(value / 7).toString() + " weeks old";
|
||||
if(value >= 7 * 7 && value < 91)
|
||||
return "Show posts less than " + Math.ceil(value / 30).toString() + " months old";
|
||||
return "Show posts from all time";
|
||||
}
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Fresh Content",
|
||||
"name": "freshCutoffDescription",
|
||||
"type": "description",
|
||||
"text": "<p>This setting allows you to choose the oldest reddit posts you’d like to see. Anything posted before the value you’ve chosen will be indicated in the browser button's total, but will not be shown in the popup."
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Popup Width",
|
||||
"name": "popupWidth",
|
||||
"type": "slider",
|
||||
"label": "",
|
||||
"max": 784,
|
||||
"min": 480,
|
||||
"step": 1,
|
||||
"display": true,
|
||||
"displayModifier": function(value) {
|
||||
return value.toString() + "px";
|
||||
}
|
||||
},
|
||||
{
|
||||
"tab": "Preferences",
|
||||
"group": "Popup Width",
|
||||
"name": "popupWidthDescription",
|
||||
"type": "description",
|
||||
"text": "<p>This setting allows you to set the width of the browser action popup."
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
+5
-3
@@ -4,7 +4,8 @@ settings = new Store('settings', {
|
||||
'cacheTime': 3,
|
||||
'timeoutLength': 5,
|
||||
'freshCutoff': 7,
|
||||
'popupWidth': 640
|
||||
'popupWidth': 640,
|
||||
'shamelessPlug': false
|
||||
});
|
||||
cache = new Store('cache');
|
||||
|
||||
@@ -634,7 +635,7 @@ RedditAPI.prototype.reportPost = function (e) {
|
||||
* @method
|
||||
*/
|
||||
RedditAPI.prototype.submitComment = function (e) {
|
||||
var listItem, fullName, status, submitButton, cancelButton, textarea, formData;
|
||||
var listItem, fullName, status, submitButton, cancelButton, textarea, comment, formData;
|
||||
|
||||
function afterSubmission (response) {
|
||||
var url, oldCache;
|
||||
@@ -659,13 +660,14 @@ RedditAPI.prototype.submitComment = function (e) {
|
||||
status = submitButton.parentNode.getElementsByClassName('status')[0];
|
||||
cancelButton = submitButton.parentNode.getElementsByClassName('cancel')[0];
|
||||
textarea = e.srcElement.parentNode.getElementsByTagName('textarea')[0];
|
||||
comment = settings.get('shamelessPlug') ? textarea.value + '\n\n*Posted from [Mostly Harmless](http://kerrick.github.com/Mostly-Harmless), a Google Chrome extension for awesome redditors.*' : textarea.value;
|
||||
|
||||
if (textarea.value === '') {
|
||||
status.innerHTML = 'There needs to be something here.';
|
||||
} else {
|
||||
formData = new FormData();
|
||||
formData.append('thing_id', fullName);
|
||||
formData.append('text', textarea.value);
|
||||
formData.append('text', comment);
|
||||
formData.append('uh', cache.get('modhash'));
|
||||
status.innerHTML = 'submitting...';
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user