Greasy Fork

Greasy Fork is available in English.

Remove from watchlist when rated

Removes rated items from watchlist while looking at item or in watchlist(sort by rated and refresh page)

目前为 2017-09-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         Remove from watchlist when rated
// @namespace    hydric
// @version      1
// @description  Removes rated items from watchlist while looking at item or in watchlist(sort by rated and refresh page)
// @author       hydric
// @match        http://www.imdb.com/*
// @grant        none
// @run-at 	     document-idle
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    var interval = setTimeout(function() {
		if (window.location.href.indexOf("title") > -1){
			if ($('.star-rating-value').length){
				$('div[title="Click to remove from watchlist"]').click();
			}
			clearInterval(interval);
		}
		if (window.location.href.indexOf("watchlist") > -1){
				var varArray = [];
				$('.star-rating-value').each(function( index ) {
					if($(this).text()  > 0){
						var datareactid = $(this).attr('data-reactid');
						var regexp = /\$.*\$(.*?)\./ig;
						var match = regexp.exec(datareactid);
						var movieidentifier = match[1];
						varArray.push(movieidentifier);
					}
				});
				var uniqueset = new Set(varArray);
				function unwatch(value1, value2, set) {
					$('div[title="Click to remove from watchlist"][data-reactid*="'+value1+'"]').click();
				};
				uniqueset.forEach(unwatch);
		}
        clearInterval(interval);
    }, 5000);
})();