Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some of the app features #58

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e5de787
Add files via upload
KFMDMSolutions Feb 3, 2022
89a28c9
Update manifest.json
KFMDMSolutions Feb 3, 2022
59ed251
Add files via upload
KFMDMSolutions Feb 3, 2022
8f824af
Add files via upload
KFMDMSolutions Feb 3, 2022
42b6a0f
Delete addQuoteLastOnlyButton.js
KFMDMSolutions Feb 3, 2022
9f563b1
Update contentScript.js
KFMDMSolutions Feb 3, 2022
02da980
Update manifest.json
KFMDMSolutions Feb 4, 2022
daa5983
Update contentScript.js
KFMDMSolutions Feb 4, 2022
4fed958
Update add_button.js
KFMDMSolutions Feb 4, 2022
54cd123
Update appcss.css
KFMDMSolutions Feb 4, 2022
ee8f58e
Update appcss.css
KFMDMSolutions Feb 4, 2022
e8a325e
Update appcss.css
KFMDMSolutions Feb 4, 2022
40ff612
Update add_button.js
KFMDMSolutions Feb 4, 2022
66da16f
Update contentScript.js
KFMDMSolutions Feb 4, 2022
7ab9e65
Add files via upload
KFMDMSolutions Feb 4, 2022
15b2726
Add files via upload
KFMDMSolutions Feb 4, 2022
9c3d0be
Add files via upload
KFMDMSolutions Feb 6, 2022
c92357c
Add files via upload
KFMDMSolutions Feb 7, 2022
f4118e8
Add files via upload
KFMDMSolutions Feb 7, 2022
04de18d
Add files via upload
KFMDMSolutions Feb 7, 2022
a67e45a
Update appcss.css
KFMDMSolutions Feb 7, 2022
0435256
Add files via upload
KFMDMSolutions Feb 7, 2022
687e46d
Update addGoogleSearch.js
KFMDMSolutions Feb 7, 2022
6f2a4e6
add some of the app features
KFMDMSolutions Feb 7, 2022
f23c89d
update the last quote img
KFMDMSolutions Feb 13, 2022
308b56a
add the new buttons to the settings page
KFMDMSolutions Feb 17, 2022
93bc14f
fix img size
KFMDMSolutions Feb 17, 2022
2527e65
Update extension/manifest.json
KFMDMSolutions Feb 23, 2022
e631879
Update extension/manifest.json
KFMDMSolutions Feb 23, 2022
7b137ca
Update contentScript.js
KFMDMSolutions Feb 23, 2022
40c6c6e
Update manifest.json
KFMDMSolutions Feb 23, 2022
62f3c71
Merge branch 'master' into master
KFMDMSolutions Feb 24, 2022
5d0b692
Update manifest.json
KFMDMSolutions Feb 24, 2022
e1fe40c
Update contentScript.js
KFMDMSolutions Feb 24, 2022
d0eb08d
Merge branch 'master' into master
KFMDMSolutions Mar 3, 2022
351183e
fix ping user
KFMDMSolutions Jun 14, 2022
5f47388
update
KFMDMSolutions Mar 13, 2023
70b6da0
update
KFMDMSolutions Mar 13, 2023
a3b3bf7
update settings page
KFMDMSolutions Mar 14, 2023
1966d59
Merge branch 'mordechairoth:master' into master
KFMDMSolutions Mar 27, 2023
a2a5c63
remove unneeded settings
KFMDMSolutions Jun 7, 2023
edfb925
Update manifest.json
KFMDMSolutions Jun 7, 2023
8232363
initialize
KFMDMSolutions May 9, 2024
6b2ef2a
Revert "initialize"
KFMDMSolutions May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions extension/css/appcss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


.clone-first .app-hidden {
display: none;
}
.clone-first.app-hidden {
display: none;
}

.post-buttons .app-hidden {
display: none;
}
4 changes: 4 additions & 0 deletions extension/css/font-awesome.min.css

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions extension/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,18 @@ select {
font-size: 0.7em;
line-height: 1;
}

.shortcut-key .icon {
display: inline-block;
font-family: FontAwesome;
font-weight: normal;
font-style: normal;
font-variant: normal;
font-size: 14px;
line-height: 1;
text-rendering: auto; /* optimizelegibility throws things off #1094 */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.shortcut-key .icon:before { padding-right: 2px; }
25 changes: 0 additions & 25 deletions extension/js/addQuoteLastOnlyButton.js

This file was deleted.

265 changes: 265 additions & 0 deletions extension/js/add_button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
function createButton(reference, customClass, title, text, onclick, itext="") {
let li = document.createElement('li');
let a = document.createElement('a');
let span = document.createElement('span');
let i = document.createElement('i');
//let img = document.createElement('img');
//img.setAttribute('src', `https://www.ivelt.com/kfmdm/resources/drawable/${icon}`)
if (reference){
a.setAttribute('href', reference);
}
if (onclick){
a.setAttribute('onClick', onclick)
}
a.setAttribute('class', 'button button-icon-only custom-btn ');
a.setAttribute('title',title );
i.setAttribute('class', `icon ${customClass} fa-fw`);
i.setAttribute('aria-hidden', 'true');
i.innerText = itext;
span.innerText = text;
a.appendChild(i);
a.appendChild(span);
li.appendChild(a);

return {li, a, span, i}
}

function getPMHref(id) {
let pm_button = document.querySelector(`#profile${id.replace("post_content", "")} .pm-icon`)
if (pm_button){
return pm_button.parentElement.getAttribute("href")
}
return null;
}

function addBtn(){
let btns = document.querySelectorAll('.post-buttons');
let isPosting = (window.location.href.includes("posting.php"));
var needUpdating = false;
btns.forEach(btn => {
// Check if custom buttons have been added already, if yes ignore.
if(btn.getElementsByClassName('custom-btn').length > 0){
return;
}
needUpdating = true
btn.querySelectorAll('li.hidden:not(.responsive-menu)').forEach(b => {
if (b.getAttribute('class') == "hidden"){
b.removeAttribute('class')
}
})

let contentElement = btn.parentElement.getElementsByClassName("content").item(0)
let id = btn.parentElement.getAttribute("id") || ""
let strippedId = id.replace("post_content", "")
strippedId = strippedId.replace("pr", "")
if (!isPosting){
addCopyQuoteButton(btn, id.replace("post_content", ""))
}
let pingOnClick = `ping_user(${strippedId})`
addSimpleButton(btn, null, 'fa-at', 'דערמאן תגובה', 'דערמאן תגובה', pingOnClick)
if (contentElement.innerHTML.includes("blockquote")) {
addQuoteLastButton(btn, isPosting);
}

let responsiveMenu = btn.getElementsByClassName('responsive-menu').item(0);
try {
btn.removeChild(btn.getElementsByClassName('responsive-menu').item(0))
}catch (e) {

}
});
let navUpdate = addDefaultPage();
if (needUpdating || navUpdate){
let navBar = document.querySelector('#nav-footer');
navBar.querySelectorAll('li.hidden:not(.responsive-menu)').forEach(si => {
si.setAttribute('class', si.getAttribute('class').replace('hidden', ''))
})
navBar.removeChild(navBar.getElementsByClassName('responsive-menu').item(0))
parseDocument($('body'));
}
}

function addSimpleButton(btn, href, customClass, title, text, onclick){
let button = createButton(href, customClass, title, text, onclick);
btn.appendChild(button.li);
}

function getQuoteURL(btn){

try{
let quoteButton = btn.querySelector('i.icon.fa-quote-left.fa-fw');
let quoteUrl = quoteButton.parentElement;
if (!quoteUrl){
return null;
}
let href = quoteUrl.getAttribute('href');
return href;
}catch (e){

}

}
function addCopyQuoteButton(btn, postID){
let href = getPMHref(postID) || getQuoteURL(btn)
if (!href){
addSimpleButton(btn, null, 'fa-copy', 'ציטיר אין אנדערע אשכול', 'ציטיר אין אנדערע אשכול', `copyQuoteParse("${postID}")`)
return;
}
addSimpleButton(btn, null, 'fa-copy', 'ציטיר אין אנדערע אשכול', 'ציטיר אין אנדערע אשכול', `copyQuote("${href}", "${postID}")`)
}
function addQuoteLastButton(btn, isPosting) {

let href = getQuoteURL(btn)
if (!href){

return;
}
var onclick = null;
if (isPosting){
onclick = "last" + btn.querySelector('i.icon.fa-quote-left.fa-fw').parentElement.getAttribute('onclick');
// button.a.setAttribute("onclick", "last" + onclick);
}
let button = createButton(href + '&last=true', 'fa-quote-left last', 'ציטיר בלויז די לעצטע תגובה', 'ציטיר לעצטע', onclick, '1');

btn.appendChild(button.li);
}


function addDefaultPage(){
if (document.querySelector(`#kf-app-default-page`)){
return false
}
let li = document.createElement("li")
let a = document.createElement('a');
li.appendChild(a)
li.setAttribute("class", "rightside")
li.setAttribute("id", "kf-app-default-page")
a.setAttribute('onClick', "saveDefaultPage()")
a.innerText = "מאך די בלאט די דיפאולט בלאט"
let pagination = document.querySelectorAll("#nav-footer").item(0)
if (pagination){
pagination.insertBefore(li, pagination.firstChild);
return true;
}
return false;
}

function getPostLink(postID){
return `https://www.IVELT.com/forum/viewtopic.php?p=${postID}#p${postID}`;
}

function copyQuoteParse(post_id){
var html = document.querySelector(`#post_content${post_id} .content`).innerHTML
let post_url = getPostLink(post_id)
var username = getUsername(post_id)
let converter = new HTML2BBCode();
html = html.replaceAll("./download", "www.ivelt.com/forum/download")
navigator.clipboard.writeText(`[quote="${username}"]${converter.feed(html)} [/quote] [url=${post_url}]מקור[/url]`)
}

function getPostDetails(post_id, prefix = 'p'){
var usernameE = document.querySelector(`#${prefix}${post_id} .username`)
if (!usernameE){
var usernameE = document.querySelector(`#p${prefix}${post_id} .username-coloured`)
}
var username = ""
if(usernameE){
username = usernameE.innerText
}

var idE = document.querySelector(`#${prefix}${post_id} .username`);
if (!idE){
var usernameE = document.querySelector(`#p${prefix}${post_id} .username-coloured`)
}
var usernameLink = ""
let id =""
if(idE){
usernameLink = idE.href;
id = usernameLink.split("u=")[1];
}
var tsE = document.querySelector(`#${prefix}${post_id} time`)
if (!tsE){
var tsE = document.querySelector(`#${prefix}${post_id} [href='#postingbox']`).getAttribute('onclick')
if(tsE)
var time = tsE.match('(?<=time:)(.*)(?=,user)')[0];
}else{
var ts = Date.parse(tsE.dateTime)
var time = ts / 1000
}



return {
"username":username,
"id":id,
"time":time
};
}

function ping_user(post_id){

if (window.location.href.includes("posting.php")){
let PostDetails = getPostDetails(post_id,"pr")
let text = `[quote="${PostDetails.username}" user_id=${PostDetails.id} time=${PostDetails.time} post_id=${post_id}]\n[/quote]`
insert_text(text)
}else{
let PostDetails = getPostDetails(post_id)
let text = `[quote="${PostDetails.username}" user_id=${PostDetails.id} time=${PostDetails.time} post_id=${post_id}]\n[/quote]`

try {
addText(text)
}catch (exception_var) {
navigator.clipboard.writeText(text)
}
}
}

function addText(text){
var textarea = document.querySelector("#message-box textarea");

if (!isNaN(textarea.selectionStart)) {
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;
mozWrapApp(textarea, text, '');
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
} else if (textarea.createTextRange && textarea.caretPos) {
if (baseHeight !== textarea.caretPos.boundingHeight) {
textarea.focus();
storeCaret(textarea);
}
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
} else {
textarea.value = textarea.value + text;
}
textarea.focus();
}
function mozWrapApp(txtarea, open, close) {
var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop;

var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd);
var s3 = (txtarea.value).substring(selEnd, selLength);

txtarea.value = s1 + open + s2 + close + s3;
txtarea.selectionStart = selStart + open.length;
txtarea.selectionEnd = selEnd + open.length;
txtarea.focus();
txtarea.scrollTop = scrollTop;

return;
}

addBtn();








5 changes: 2 additions & 3 deletions extension/js/contentScript.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
let scripts = [
"js/keyboardShortcuts.js",
"js/removeNestedQuotes.js",
"js/addQuoteLastOnlyButton.js",
"js/newResponseNotification.js",
"js/addGoogleSearch.js",
"js/sefariaLinker.js"
"js/add_button.js",
"js/last_quote.js"
];

scripts.forEach(s => {
Expand Down
2 changes: 1 addition & 1 deletion extension/js/keyboardShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function checkKey(e) {
}
}

document.querySelector(".icon-search-active a").accessKey = "a";
document.querySelector(".icon.fa-file-o.fa-fw.icon-blue").parentElement.accessKey = "a";

const notificationNode = document.getElementById("notification_list_button");

Expand Down
Loading