Problem with JS code
2 posters
Page 1 of 1
Problem with JS code
Technical Details
Forum version : #phpBB3
Position : Administrator
Concerned browser(s) : Mozilla Firefox, Google Chrome
Who the problem concerns : All members
When the problem appeared : long ago
Forum link : https://www.darmowybonus.com/
Description of problem
Hello, I have a problem with my JS code. If i open a topic, I have to wait a few seconds. Can I exchange this code for another one? This code converts the text into a link. Maybe it is available other solution changing phrases for links?- Code:
$(function(){
$(".post .postbody").each(function(){
var _1=$(this).html();
var _2=_1.replace(/Bob Casino/gi,"<a target='blank' href='https://www.bobregister.com/refer/71c306cf'>Bob Casino</a>");
$(this).html(_2);
var _1=$(this).html();
var _2=_1.replace(/Melbet/gi,"<a target='blank' href='http://refpahah.xyz/L?tag=d_40498m_2170c_&site=40498&ad=2170/'>Melbet</a>");
$(this).html(_2);
var _1=$(this).html();
var _2=_1.replace(/1xbit/gi,"<a target='blank' href='http://referrer.website/L?tag=d_35028m_1732c_&site=35028&ad=1732'>1xbit</a>");
$(this).html(_2);
});
});
The whole code has ~1200 lines
Last edited by testyforum on Sat 14 Sep - 9:49; edited 1 time in total
Re: Problem with JS code
Hello,
If I understood this right, you want to replace certain text on your forum with links. Your solution is not the most efficient. This one should do the trick and be less lengthy, while also hopefully much faster:
You need to modify this part:
If the code doesn't work, keep it on your forum and post a link to a topic where it is supposed to do modifications.
If I understood this right, you want to replace certain text on your forum with links. Your solution is not the most efficient. This one should do the trick and be less lengthy, while also hopefully much faster:
- Code:
;var d=document;function _q(e){return d.querySelectorAll(e)};function l(e, ev, c){e.addEventListener(ev, function(f){c(f)})};
var links={
"Bob Casino":"https://www.bobregister.com/refer/71c306cf",
"Melbet":"http://refpahah.xyz/L?tag=d_40498m_2170c_&site=40498&ad=2170",
"1xbit":"http://referrer.website/L?tag=d_35028m_1732c_&site=35028&ad=1732",
};
l(d, 'DOMContentLoaded', function(){
var posts=_q(".postbody .content"), p;
posts.forEach(post=>{
p=post.innerHTML;
Object.entries(links).forEach(item=>{
p=p.replace(new RegExp(item[0], "gi"), "<a href='"+item[1]+"'>"+item[0]+"</a>");
});
post.innerHTML=p;
});
});
You need to modify this part:
- Code:
var links={
"Bob Casino":"https://www.bobregister.com/refer/71c306cf",
"Melbet":"http://refpahah.xyz/L?tag=d_40498m_2170c_&site=40498&ad=2170",
"1xbit":"http://referrer.website/L?tag=d_35028m_1732c_&site=35028&ad=1732",
};
If the code doesn't work, keep it on your forum and post a link to a topic where it is supposed to do modifications.
Guest- Guest
Re: Problem with JS code
Problem solved & topic archived.
|
Similar topics
» CSS code problem
» Welcome code problem
» Problem in this code
» what is the problem in this JS code
» I have a problem in this code ..
» Welcome code problem
» Problem in this code
» what is the problem in this JS code
» I have a problem in this code ..
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum