I tried remove a link on a div, and it works using unwrap(), see it on jsfiddle
Now, I want implement a userscript to remove the link on a website (example on jsfiddle), but it's not working.
I'm using Tampermonkey. Here's my userscript:
// ==UserScript==
// @name           Remove Link
// @include        http://jsfiddle.net/dv3Fm/2/embedded/result/
// ==/UserScript==
function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "http://code.jquery.com/jquery-1.9.1.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "(" + callback.toString() + ")();";
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}
// the guts of this userscript
function main() {
 $('.spoiler a > .smallfont').unwrap();
}
// load jQuery and execute the main function
addJQuery(main);
Here's the HTML:
<div class="spoiler">
    <!--I want remove link only -->
    <a href="http://www.domain.com" target="_blank">
        <div class="smallfont" id="bbcode_div"/>        
        </div>
    </a>  
</div>
<!--I want result such as : -->
 <div class="spoiler">
        <div class="smallfont" id="bbcode_div"/>        
        </div> 
</div>
What is my userscript doing wrong? How can I remove the link using unwrap jQuery in a userscript?
 
     
    