8000 2015, added quote on all pages · cpluspluscom/EnhancedCpp.com@a5201ce · GitHub
[go: up one dir, main page]

Skip to content

Commit a5201ce

Browse files
author
Ronak Gajrawala
committed
2015, added quote on all pages
1 parent a65cd9e commit a5201ce

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 - Mauro Grassia
1+
Copyright (c) 2014-2015 - Mauro Grassia
22

33
Permission is hereby granted, free of charge, to any person or organization
44
obtaining a copy of the software and accompanying documentation covered by

js/enumerate.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function RunPageEdit() {
22
var isEditablePage = 0;
33
do {
44
// Can I reply? (aka Can I quote a post?)
5-
var canReply = +(document.getElementsByClassName('postreply').length !== 0);
5+
var canReply = +(document.querySelector('#CH_subscription > form > select').children.length > 2);
66
var currentTopic = document.location.pathname;
77

88
// Parse Topic ID
@@ -103,18 +103,27 @@ function RunPageEdit() {
103103
var js_quote_code = 'for_Post.prototype.quote = ' + (function() {
104104
var result = getpostinternal(this.postid);
105105
if (result !== 'error') {
106-
var reply = document.getElementById('CH_reply').getElementsByTagName('a');
107-
if (reply[0].href.indexOf('javascript:thread') === 0) {
108-
eval(reply[0].href.substr(11) + ';');
109-
}
110-
reply = document.getElementById('CH_reply').getElementsByTagName('textarea');
106+
var pages = document.querySelector('.C_pages');
107+
var on_last_page = pages ? !!pages.lastChild.title : true;
111108

112109
var replier = this.el.innerHTML;
113110
var begin = replier.indexOf('<b>');
114111
var end = replier.indexOf('</b>');
115-
116112
replier = (begin > 0 && end > 0) ? ('=' + replier.substring(begin + 3, end)) : '';
117-
reply[0].value ='[quote' + replier + ']' + result + '[/quote]';
113+
114+
if (on_last_page) {
115+
var reply = document.getElementById('CH_reply').getElementsByTagName('a');
116+
if (reply[0].href.indexOf('javascript:thread') === 0) {
117+
eval(reply[0].href.substr(11) + ';');
118+
}
119+
reply = document.getElementById('CH_reply').getElementsByTagName('textarea');
120+
121+
reply[0].value = '[quote' + replier + ']' + result + '[/quote]';
122+
} else {
123+
localStorage.setItem('q_body', '[quote' + replier + ']' + result + '[/quote]');
124+
localStorage.setItem('q_tid', window.location.pathname.split('/').slice(3,4)[0]);
125+
window.location.href = pages.lastChild.href;
126+
}
118127
}
119128
}).toString() + ';';
120129

js/quote.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var q_body = localStorage.getItem('q_body');
2+
var q_tid = localStorage.getItem('q_tid');
3+
if (q_body && q_tid && window.location.pathname.indexOf(q_tid) !== -1 && document.getElementById('CH_reply')) {
4+
var reply = document.getElementById('CH_reply').getElementsByTagName('a')[0].click();
5+
reply = document.getElementById('CH_reply').getElementsByTagName('textarea');
6+
7+
reply[0].value = q_body;
8+
}
9+
localStorage.removeItem('q_body');
10+
localStorage.removeItem('q_tid');

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"content_scripts" : [
2222
{
2323
"matches" : ["http://www.cplusplus.com/*"],
24-
"run_at" : "document_end",
25-
"js" : ["options/js/defaults.js", "js/options.js", "js/base.js", "js/transform.js", "js/enumerate.js", "js/main.js"],
24+
"run_at" : "document_idle",
25+
"js" : ["options/js/defaults.js", "js/options.js", "js/base.js", "js/transform.js", "js/enumerate.js", "js/main.js", "js/quote.js"],
2626
"css" : ["css/style.css"]
2727
},
2828
{

options/options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h3><b><a href="http://www.cplusplus.com/forum/">Forum</a></b></h3><ul>
107107
</div>
108108
<div id="I_bottom">
109109
<div id="I_footer">
110-
<a href="http://www.cplusplus.com/">Home page</a> | <a href="http://www.cplusplus.com/privacy.do">Privacy policy</a><br>© cplusplus.com, 2000-2014 - All rights reserved - Addon Options Page - <i>v3.1</i><br><a href="http://github.com/cpluspluscom/EnhancedCpp.com">Spotted an error? contact us</a>
110+
<a href="http://www.cplusplus.com/">Home page</a> | <a href="http://www.cplusplus.com/privacy.do">Privacy policy</a><br>© cplusplus.com, 2000-2015 - All rights reserved - Addon Options Page - <i>v3.1</i><br><a href="http://github.com/cpluspluscom/EnhancedCpp.com">Spotted an error? contact us</a>
111111
</div>
112112
</div>
113113
<script src='js/defaults.js'></script>

0 commit comments

Comments
 (0)
0