inherit
206120
0
Mar 14, 2014 20:15:09 GMT -8
fj76ts4
3
March 2014
fj76ts4
|
Post by fj76ts4 on Mar 1, 2014 9:10:46 GMT -8
This is my current code: <script type="text/javascript"> /*Autocard by fj76ts4
Based on Link-to-Profile tag by Malagrond
Do not remove this header!! */ <!--
document.body.innerHTML = document.body.innerHTML.replace(/\[c\](.+?)\[\/c\]/gi, "<a href=\"www.magiccards.info/autocard.php?card=$1\">$1</a>"); //--> </script>
It goes in the global footer, as expected. What it's supposed to do is replace [c]cardname[/c] with the relevant link on magiccards.info, except what happens is it replaces [c]cardname[/c] with the thread url with the thread url before it, so instead of [c]anger[/c] getting you a link to www.magiccards.info/autocard.php?card=anger, it creates a link to jstest.freeforums.net/thread/2/www.magiccards.info/autocard.php?card=anger, and I have no idea why. Can anybody help?
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 1, 2014 22:41:24 GMT -8
You would need to prepend the prototcol (e.g. http://) or at least include the double-slash (e.g //) to make it a protocol-relative url else it will be treated as domain relative and appended to the end of the current url as you say it is doing now example: "<a href=\"http://www.magiccards.info/autocard.php?card=$1\">$1</a>"
As for the code itself, I would not recommend using it on a V5 forum.
|
|
inherit
206120
0
Mar 14, 2014 20:15:09 GMT -8
fj76ts4
3
March 2014
fj76ts4
|
Post by fj76ts4 on Mar 2, 2014 5:39:49 GMT -8
oh wow t.t
thank you so much!
also, why shouldn't this be used on a v5 forum?
(sorry, i'm still pretty new to proboards)
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Mar 2, 2014 19:40:48 GMT -8
because of the way it is overwriting the entire body html, it will unbind all events on any object inside the body element.. which is all of them. so any dynamically added objects will get stripped of their powers.
this would be a better version:
<script type="text/javascript"> $('tr.item.post td.content div.message').each(function() { if ($(this).html().match(/\[c\](.*?)\[\/c\]/)) { $(this).html($(this).html().replace(/\[c\](.*?)\[\/c\]/g, '<a href="http://www.magiccards.info/autocard.php?card=$1\">$1</a>')); } }); </script>
|
|
inherit
206120
0
Mar 14, 2014 20:15:09 GMT -8
fj76ts4
3
March 2014
fj76ts4
|
Post by fj76ts4 on Mar 2, 2014 22:37:22 GMT -8
all right, thanks! That would explain some things, I'll remember this in the future.
|
|