Jump to content

User:NewsAndEventsGuy/common.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by NewsAndEventsGuy (talk | contribs) at 12:12, 12 August 2019 (Annotate, Disable importscript, and copy contents of test.js Expect this to reproduce the show button problem on the "same paragraph" test page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//In my last test, there was no problem.  In the last test the entire
//contents of this file were 
//            importscript('|User:NewsAndEventsGuy/test.js');
//and test.js consisted of the javascript code below, which I have copied here
//in its entirety. I expect the show button on the "same paragraph" test
//page to be disabled for reasons unknown.    The test pages are 
//     [[User:NewsAndEventsGuy/ShowButtonTest-DifferentParagraphs]]
//     [[User:NewsAndEventsGuy/ShowButtonTest-SameParagraph]]

mw.hook( 'wikipage.content' ).add( function( $content ) {
    var href,
    	links = $content.find( 'a[href^="#CITEREF"]' );

    links.each( function (i, elem) {
    	href = elem.getAttribute( 'href' ).substring(1); //skip the #
        if ( 1 < 3) {
            elem.parentNode.innerHTML += "harv error";}
    } );

});
 
// Save this comment in case it sheds light
	// IDs can contain characters like . that have meaning in selectors
	// use $.escapeSelector to make sure they are escaped