tidusx18
7/10/2017 - 4:02 PM

LoadTuritinSource.js

// ==UserScript==
// @name         Auto Select Turnitin Field Values
// @namespace    http://tampermonkey.net/
// @version      0.1
// @match        https://api.turnitin.com/t_modify_assignment.asp?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
	
	var title = document.getElementById('title').value;

    var startHour = document.querySelector("select[name=start_hour]");
	var startMinute = document.querySelector("select[name=start_minute]");
	var startPeriod = document.querySelector("select[name=start_ampm]");

	var dueHour = document.querySelector("select[name=due_hour]");
	var dueMinute = document.querySelector("select[name=due_minute]");
	var duePeriod = document.querySelector("select[name=due_ampm]");

	var postHour = document.querySelector("select[name=post_hour]");
	var postMinute = document.querySelector("select[name=post_minute]");
	var postPeriod = document.querySelector("select[name=post_ampm]");
	
	if(title.toLowerCase().includes('late')) {
		startHour.selectedIndex = 10;
		startMinute.selectedIndex = 56;
		startPeriod.selectedIndex = 1;

		dueHour.selectedIndex = 10;
		dueMinute.selectedIndex = 55;
		duePeriod.selectedIndex = 1;

		postHour.selectedIndex = 10;
		postMinute.selectedIndex = 56;
		postPeriod.selectedIndex = 1;
	}
	else {
		startHour.selectedIndex = 4;
		startMinute.selectedIndex = 0;
		startPeriod.selectedIndex = 0;

		dueHour.selectedIndex = 10;
		dueMinute.selectedIndex = 55;
		duePeriod.selectedIndex = 1;

		postHour.selectedIndex = 10;
		postMinute.selectedIndex = 56;
		postPeriod.selectedIndex = 1;
	}

})();
// ==UserScript==
// @name         Submit/Save Hotkey (Ctrl + s)
// @namespace    https://github.com/tidusx18
// @version      0.0.1
// @description  Overrides browser default action for "Ctrl + s" hotkey to submit/save the current form/page.
// @author       You
// @match        https://fiu.blackboard.com/*
// @match        https://cp.fiu.edu/*
// @match        https://api.turnitin.com/t_modify_assignment.asp?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

  // NOTE: Refactor with specifically targeted elements this will work with.

	document.addEventListener("keydown", function(e) {
    submitPage(e);
	}, false);

  try {
    getInstances(); // When hotkey pressed and focus is in TinyMCE editor
  } catch(e) {
      if(e instanceof ReferenceError) {
        console.log('TinyMCE is not defined.');
      }
  }

  function submitPage(e) {
    if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
      e.preventDefault();

      var submit = document.querySelector("input.submit"); // Common edit pages
      if (submit) {
        submit.click();
      }

      var update = document.querySelector("form input[value='Update']"); // TinyMCE HTML Popup
      if (update) {
        update.click();
      }

      var backLink = document.querySelector("p.backLink a"); // "Ok" buttons to return to previous page
      if (backLink) {
        backLink.click();
      }

      var closeButton = document.querySelector("[aria-labelledby=ui-id-6] .ui-dialog-buttonset button"); // CreatorPro
      if (closeButton) {
        closeButton.click();
      }
		
	  var submitButton = document.querySelector("#ibox_form_footer input"); // Turnitin
      if (submitButton) {
        submitButton.click();
      }
    }
  }

  function getInstances() {
    return tinyMCE.onAddEditor.add( function(mgr,ed) {
            ed.onKeyDown.add( function(ed, e) {
              submitPage(e);
            });
          });
    }
})();
// ==UserScript==
// @name         Load Turnitin Source
// @namespace    http://tampermonkey.net/
// @version      0.1
// @match        https://fiu.blackboard.com/webapps/turn-plgnhndl-BBLEARN/content/modify.jsp?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var turnitinFrameSrc = document.getElementById("basic_iframe").src;
	window.location.href = turnitinFrameSrc;
})();