Search the Community
Showing results for tags 'soundcloud'.
-
I've been trying to make an extension for embedding plain text links on imageboards like 4chan. I've taken code from a more fully featured extension that has features that I really don't want because it's incompatible with the more popular extensions out there. I have it working as an extension in my browser, the edited full version of it, but when I pack it for installation and re-install it, it throws errors like "Uncaught TypeError: Cannot read property 'links1' of undefined". I don't know much about JS but I'm wondering why it's not throwing this error in the original version where it's edited but throws the error on the one installed from the packed crx file. var links = /((?:https?|ftp)://[^s'"'<>()]+|www.[^s'"'<>()]+|[-w.+]+@(?:[-w]+.)+[w]{2,6})/gi; function apply() { if (!window.location.href.match(/boards./)) return false; var a = document.getElementsByTagName("iframe"), b = document.getElementsByTagName("embed"); Activate(a,b); } function Activate(a, b) { a = a ? a + " " : ""; for (var d, c = xpath((a == "" ? "." : "id('" + a.substr(1, a.length - 2) + "')") + "//text()[ancestor::blockquote]"), e = 0; e < c.snapshotLength; e++) { d = c.snapshotItem(e); d != null && linkActivation(d); } } function linkActivation(a) { for (var b, d, c = a.textContent, e = null, g = 0, f = {}, youtube, vocaroo, soundcloud; (d = links.exec(c)) !== null;) if (!f[d[0]]) { f[d[0]] = true; null === e && (e = document.createElement("span")); b = d[0].replace(/.*$/, ""); e.appendChild(document.createTextNode(c.substring(g, d.index))); if (!b.match(/.4chan.org/i)) { b = (youtube = b.match(/youtube.com/watch?.*?v=([a-z0-9-_#!]+)/i)) && (settings.youtube1 != "off" && !inThread || settings.youtube2 != "off" && inThread) ? '<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/' + youtube[1] + '?wmode=opaque" frameborder="0"></iframe><br /><a href="' + b + '" target="_blank">' + b + "</a>" : (vocaroo = b.match(/vocaroo.com/(i/|?media=)([a-z0-9]+)/i)) && (settings.vocaroo1 != "off" && !inThread || settings.vocaroo2 != "off" && inThread) ? '<object type="application/x-shockwave-flash" style="width: 148px; height: 44px" data="http://vocaroo.com/player.swf?playMediaID=' + vocaroo[2] + '&server=m1.vocaroo.com&autoplay=0""><param name="movie" value="http://vocaroo.com/player.swf?playMediaID=' + vocaroo[2] + '&server=m1.vocaroo.com&autoplay=0"></object><br /><a href="' + b + '" target="_blank">' + b + "</a>" : (soundcloud = b.match(/((www.)?soundcloud.com/([a-z0-9-_]+/?)+)/i)) && (settings.soundcloud1 != "off" && !inThread || settings.soundcloud2 != "off" && inThread) ? '<object height="81" width="400"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http://' + soundcloud[1] + '&g=bb"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http://' + soundcloud[1] + '&g=bb" type="application/x-shockwave-flash" width="400"></embed></object><br /><a href="http://' + soundcloud[1] + '" target="_blank">http://' + soundcloud[1] + "</a>" : b.indexOf("@") > -1 && (settings.email1 != "off" && !inThread || settings.email2 != "off" && inThread) ? "<a href='mailto:" + b + "'>" + b + "</a>" : settings.links1 != "off" && !inThread || settings.links2 != "off" && inThread && b.indexOf("@") < 0 ? "<a href='" + (b.match(/^http/i) ? b : "http://" + b) + "' target='_blank'>" + b + "</a>" : b; e.innerHTML = b; g = d.index + d[0].length; } } if (e) { e.appendChild(document.createTextNode(c.substring(g, c.length))); try { a.parentNode.replaceChild(e, a); } catch (h) { console.error(h); } } } function xpath(a) { return document.evaluate(a, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null) } apply();
- 9 replies
-
- javascript
- extension
-
(and 4 more)
Tagged with: