使用 Greasemonkey 覆盖匿名功能

问题描述

我正在尝试使用 Greasemonkey 更改此代码以不使用“world”,而是使用 window.location.href 以便在选择下拉选项时,它保持在同一页面上,但只更改 suid。

页面代码

$folderPath = 'M:\abc\WORKFORCE\Media\Attachments' 
 
Write-Host "Executing Script..." 
 
foreach ($file in Get-ChildItem $folderPath -file)
{
       # execute code 
}

我的尝试:

<script type="text/javascript">
$('#charselectdropdown').on('select2:select',function (e) {
  var data = e.params.data;
  if(data.id > 0) {
    window.location = '/world?suid=' + data.id + '&serverid=2';
  }
  else {
    window.location = '/myaccount';
  }
});
</script>

我也试过用这个:

功能

// ==UserScript==
// @name           The OW Helper
// @include        *.outwar.com/*
// @exclude        *.outwar.com/myaccount*
// @require        https://gist.github.com/raw/2620135/checkForBadJavascripts.js
// @require        http://code.jquery.com/jquery-latest.js
// @grant          GM.setClipboard
// @grant          GM_openInTab
// @grant          GM_registerMenuCommand
// @grant          GM_addStyle
// @run-at         document-start

// ==/UserScript==
(function (w) {
    function pre_script_execute_handler (e) {
        var target = e.target;
        if (target.innerHTML.indexOf("$('#charselectdropdown').on(") != -1) {
            console.log('Removed');
            e.preventDefault();
            e.stopPropagation();
            addBack();
        }
    }
  
    w.addEventListener('beforescriptexecute',pre_script_execute_handler);

    function addBack () {
      console.log('Adding new');
      
      w.$('#charselectdropdown').on('select2:select',function (e) {
        var data = e.params.data;

        if(data.id > 0) {
          window.location = '/' + window.location.href + '?suid=' + data.id + '&serverid=2';
        }
        else {
          window.location = '/myaccount';
        }
      });
    }


}) (unsafeWindow);

这些似乎都不适合我。谁能告诉我这是什么问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)