Skip to content

Script that works in Tampermonkey doesn't in Violentmonkey. #172

@Betsy25

Description

@Betsy25

What is the problem?

Some scripts that do work in Tampermonkey, don't in Violentmonkey. (One of them posted below)

How to reproduce it?

  • 1: Have this script installed :
// ==UserScript==
// @name         Github - Color issues title blue & scroll to last message on title click.
// @namespace    rtasegase54tw54zwe54t
// @version      0.2
// @description  Color issues title blue and scroll to last comment on title click.
// @author       Me
// @match        https://github.com/*/*/issues*
// @require      https://code.jquery.com/jquery-3.2.1.min.js
// @grant        none
// ==/UserScript==
(function(){
    var s=document.createElement("style");
    s.innerHTML=".js-issue-title{color:blue;cursor:pointer}";
    document.querySelector("head").appendChild(s);
    //Define timer variable
    var timer=false;
    //Registers events
    var addClickEvent=function(){
        //Register our event again
        $('.js-issue-title').off("click");
        $('.js-issue-title').on("click",function(){
            $("html, body").animate({
                scrollTop: $('.timeline-comment-header').last().offset().top
            }, 200);
        });
    };
    //Schedule a timer event
    var scheduleUpdater=function(){
        //Only if we have not already scheduled
        if(!timer)
        {
            //run function in timer that registers click events and resets the timer
            timer=window.setTimeout(function(){addClickEvent();timer=false;},100);
        }
    };
    //Watch over document changes
    document.body.addEventListener('DOMSubtreeModified', function (){
        //Do not update immediately, otherwise we can run into an infinite loop.
        scheduleUpdater();
    }, false);
    //Register event for all existing elements
    addClickEvent();
})();
  • 2: Open an issue on a Github issues page, for example some issue from this issue forum here
  • 3: With Tampermonkey, the script works as it should, that is, the issue title would be colored blue, and when clicked the page would scroll to the last comment on the page. With Violentmonkey, the script doesn't work.

What is the expected result?

Script should do as explained in step 3 above.

What is the actual result?

Nothing at all.

Environment

  • Browser: Firefox
  • Browser version: v55.0.1 (32bit) (same in current FF nightly)
  • Violentmonkey version: 2.6.4
  • OS: Win7 64bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions